Could ya help me with my for loop?


here's my for loop that is apparently infinity and crashing my browser:

for(var i=9; i<20; i--);

the syntax seems fine to me, I'm trying to count down one by one from 20 to 9, whats wrong with it?


Switch your 9 and 20. the number it starts with should be right after var. I did the same thing.


ohh ok i switched it around

so I after changing it to
for(var i=20; i<9; i--)

i ran it, and it didn't crash the browser, but it also didn't print out the numbers to the console like i thought it would

it s just blank..


Well if you want to see the numbers printed you need to print the numbers:

for(var i=20; i>9; i--) 

Also using a semicolon after the loop might make it pointless if you not only intend to count down.
Here is a post about why and when you can omit the {} and what a semicolon after conditions does:


ok i just went back and tried to print it to the console, and again it was blank. here's the code i submitted:

for(var i=20; i<9; i--)


Sry my fault you of course need to change the condition to i >9 (fixed it in my post). So you start with var i=20 and as long as i is > 9 you keep looping.


lol I'm having the same problem...