I don't know what they want me to change


#1



It crashes when I run it


var understand = true;

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


#2

The above is a statement in a conditional expression, which is invalid. We do not compare objects using the assignment operator, but using the equality ( ==), or, identity, (===) operators.

When evaluating a Boolean, we need no comparison:

if true then do this, else do that.

It already is true, and if not, it doesn't matter. The branch will not be executed unless it is.


#3

var understand = true;

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

Crashes my browser


#4

In this instance you are making an assignment with an identity operator. No assignment is being made.

understand = false;

That sets (assigns) the new value.

As mentioned above, this is overkill, and not a best practice that speaks to a limited understanding of conditional expressions and booleans. Recommend take some time to review the fundamentals or this type of thinking will follow you everywhere and never get corrected.


#5

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