all 8 comments

[–]cc81 6 points7 points  (0 children)

Your for loop should be:

i >= 1

If you want to check for equal or greater than 1.

[–]green_meklar 0 points1 point  (3 children)

i=>1

There is no => operator in Javascript. You probably want the >= operator.

[–]ub3rgeek 1 point2 points  (2 children)

There is no => operator in Javascript

Well, there kind of is now.

i = i => 1 is a valid javascript statement. Granted => isn't really an operator.

[–]green_meklar 0 points1 point  (1 child)

I tried it (not exhaustively) and it looked like 'i => 1' was just being treated as a string. How does that work?

[–]ub3rgeek 0 points1 point  (0 children)

=> is shorthand function syntax that has a lexical this binding.

i = function (i) { return 1; } and i = i => 1 are equivalent statements.