Add charAt when looping through string for IE8