That's right, but JS is very permissive.
And that's the first mistake, you are setting n to 0 here, you should always use === in JS to compare object.
2nd one: in for (var i = 0; n; i++), you will never enter that since n equal 0
3rd one: It's an infinite look, if n > 0 because you will never reach the condition, I bet you wanted to write i < n instead of n.
4 incoming one, since you are using JS be careful when playing with string because "-2" < "-20" === true