views:

10

answers:

1

In the chrome console, I can't run any loops. Why is this?

For example, the following will give a syntax error of "Expected '('"

for each (var item in [1, 2, 3]) alert(item)
+1  A: 

each isn't a Javascript keyword. See the W3Schools page on Javascript's for statement for reference.

Try the following:

for ( var item in [1,2,3] ) alert(item)
Stephen Jennings
I'm running chrome and tested this. It works. Also, I'd never opened Chrome's js console. Holy crap this thing is firebug built into the browser...
Tim Coker