Page keeps crashing!


#1

It said don't change line 5! So, I didn't, but it crashes anyway... I'm on chrome not sure if it matters... I tried changing the equation also.... even giving it rest for a day.

var understand = true;

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

#2

Hint:

1 will always be greater than 0.


#4

ohhhh... I feel stupid


#5

Thanks!
:open_mouth:


#6

I'm afraid I still don't get it. If I type in a condition that is true, the loop will run infinitely and crash my browser. If I use a false condition, it won't do anything at all. Am I supposed to set a condition that will make "understand" true or false, or what?


#7

That's correct. So what you need to do is set up a condition that starts to be true and turns false while you're looping.


#8

But doesn't the boolean become false when you set it false?
That's why I thought

while( understand = true ){
console.log("I'm learning while loops!");
understand = false;
}
should be right, but it isn't.


#9

The problem with your code is this:

understand = true

namely = is an assignment operator and not a comparison operator which has the side effect that the whole statement understand = true has the value you assign. Now the value you assign is true so understand = true behaves as if you'd written true as condition. Sure this understand = false set understand to false, but you're condition turns it to true regardless of what is has been before.


#10

Kay, noticed the problem.
Should use === instead of =