For or While


So I have this

for (var i = 1; 1 <101; i++) {

but I keep getting an infinite loop and it crashes my browser, I never really got the hang of loops because in every question with them I always got infinite loops :confused:


change 1<101 to i<101 and it should work :smile:


Loops run when their condition is true and your is independent of variables and always true: 1 is less then 101 and always will be. As @tomkur2 already implies you could fix this by using i instead of 1.
Also if you have trouble with loops maybe this is overview is helpful for you: