While syntax


I’m being told “It looks like you didn’t print the string to the console. Check your loop syntax!”

I’m sorry to be asking so much, I’m really struggling with Javascript! I know I’ll get there, but for now, can anyone spot my error?

<In what way does your code behave incorrectly? Include ALL error messages.>


var understand = true;

while(understand= 0){
console.log(“I’m learning while loops!”);
understand = false;

<do not remove the three backticks above>



What they are trying to achieve,
that you are able to use a while-loop.

             point of entry
             in while-loop
 ->  while ( condition===true )   -->EXIT--->if condition===false
|       {  // begin of while-code-block  
|          // your code that will be executed 
|          //       as long as while-condition === true
^<- - - } //end of while-code-block, 
                     while-condition is checked again !! 

They give you the code:

var understand = true;

	console.log("I'm learning while loops!");
	//Change the value of 'understand' here!
	understand=false;   //<<== you make sure

1 You assign true to the variable understand

2 The while-statement -tests the condition-,
–which is the variable understand with its value being true
3 Access is granted to the while-code-block
4 console.log(“I’m learning while loops!”); is executed.
5 assignment of the false value to the variable understand
6 END of while-code-block is reached,
goto 2 //The while-statement -tests the condition-, understand

As understand renders to false,
the while will NOT execute its body,
and will EXIT.


google search
== the Book ==
javascript while site:developer.mozilla.org

== discussions / opinions ==
javascript while vs do while site:stackoverflow.com

== guidance ==



you have to write the statement
console.log(“I’m learning while loops!”);
in the last console.log.

in the beginning the condition is false, which means 0 . After the random function generates the 1 the while loop will stop because the condition is now 1 and that is the point where you have to enter your new console.log

got it ?


Wow @leonhard.wettengmx.n- thank you so much for this thorough explanation!


Thank you @mchoeti! I got it :slight_smile: I see now what I did wrong. Thank you so much!