1

Anyone knows why this isnt working in IE7 and how I can make it work?

var test = "hello";
for (var i = 0, len = test.length; i < len; i++) {
    alert(test[i]);
}

or see http://jsfiddle.net/75Cqt/

1
  • @IgorDymov: Drat, was kind of hoping it wasn't a duplicate. :-) Commented Feb 12, 2013 at 12:22

2 Answers 2

3

IE7 doesn't support indexing into strings with [i], you have to use charAt(i). E.g.:

var test = "hello";
for (var i = 0, len = test.length; i < len; i++) {
    alert(test.charAt(i));
}
Sign up to request clarification or add additional context in comments.

Comments

0

Try test.charAt(i) in place of char[i]

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.