Why is this while loop crashing the browser?


#1

function sololoop(){
var ite = 89;
while (ite<90)
console.log("looped once!");
ite++;
ite<91;

}
sololoop()


#2

Because you're missing the {} after the while loop. This is ok, but it means that it will only work on the very next statement which is in you're case the console.log so your effective loop is this:

[var ite = 89;] // just to show that the condition is true
while (ite<90)
console.log("looped once!");

the whole rest will only be executed when this loop is done, which is never. So wrap the stuff you want to belong to the loop inside of {}.


#3

coz your condition is true ..remember while loop is whatever its true it runs forever...

so you have to make it false. and then its gonna stop


#4

He (or she) tried to make it false by ite++;. But as said the problem is that this part does not belong to the loop because of the missing {}.


#5

Thank you very much!