Why is this infinite?



it's an infinite loop. I'm not sure why. what should my condition be?

var understand = true;

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


We cannot write an assignment in a conditional expression. Remove = true.

while (understand) {


The "=" in JavaScript is the assignment operator, not a comparison operator.
The comparison operator is "===".
So you should write either this:

 while (understand === true)

or this:



This is redundant, and a habit to steer away from, imho.


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