While syntax


var understand = true;

console.log("I'm learning while loops!");
understand = false;
Why doesn't this work?? help.thx


while(understand) {


thank you so much it worked!


what neither answers explain is that if you do:


there is no need to check condition, understand is true, so the loop gets executed. Then understand becomes false, and the loops exits. You surely remember a if statement, usually you use them to check something:

if (3 < 5){ /* do something */ }

but you can also just do:

if (true){ /* do something */ }

same for loops