Is this an infinite loop!


#1

My computer is freezing up and buffering when I try to run this, is it an infinite loop, I tried it on another laptop same thing?

var monster= true;
while(monster);
{ console.log("I love dragons");
monster=false;
}

for (var a=0; a< 20; a++);
{console.log(a);
}


#2

Hi, @sarahharrison ,

You have a semicolon at the end of the line here ...

while(monster);

... and here ...

for (var a=0; a< 20; a++);

Those semicolons terminate the statements, and cut off the loop headers from the intended content of the loops.


#3

Thank you so much! @appylpye


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.