2. while syntax


#1

var understand = true;

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

what it does not work?
instructions: Try it yourself—complete the while loop in the editor so it will print out "I'm learning while loops!". Do this by adding the condition between the parentheses—don't change line 5, or you could get an infinite loop!


#2

while(understand = 0){

we use = for assigment if we want to compare two value then we shoud use == or ===

so your while loop should be like
while(understand){
or
while(understand == true){
or
while(understand === true){

and
we use 0 for false and 1 for true


#3

thanks rcodeman....fixed


#4

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