What's the role of this?!


#1


var understand = true;

while( understand === true){
	console.log("I'm learning while loops!");
	understand = false;
}

please can someone explaine to me why they write understand = false; what's the role of it ?!


#2

We declared

understand = false;

to stop the looping, because as long as the condition evaluates to true, the loop will continue to run. and if your loop continue to run, your browser will crash.


#3

i understand now thank you :relaxed:


#4

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