2. while syntax - just dont know what to do


#1


https://www.codecademy.com/courses/javascript-beginner-en-ASGIv/0/2?curriculum_id=506324b3a7dffd00020bf661

hey. just basically dont understand what im required to do? it says its should simpler and that i just need to 'Do this by adding the condition between the parentheses—don't change line 5, or you could get an infinite loop!'
what do i have to do exactly? what condition? no one else seems to be having this problem


var understand = true;

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


#2

your while loop has a condition:

while()

well, not yet, the brackets are still empty. with condition it would like this:

while(condition)

condition is just a placeholder word, you can put understand inside:

while(understand)

since understand is true, the loop will run, then in the loop understand is set to false, the loop won't run again (don't remove the understand = false; it will cause an infinity loop


#3

Hi the condition should be understand

while(condition){
    // Do something!
}

#4

thanks guys i just was finding it hard to think about but i totally get it now maybe i just needed to step away from it for a while as well


#6

I added while(understand = true) why did this cause an endless loop?


#7

because you assign a value of true to your understand variable, which means understand will always be true, causing a infinity loop, you want to compare understand with true, use two equal signs