2.while syntax


#1

var understand = true;

while(understand=0 ){
console.log("I'm learning while loops!");
understand = false;
}
i cant figure out the err.
kindly guide me


#2

in the while condition:

while(understand=0  )

you should compare understand with true, not with zero. to compare, use two or three equal signs, a single equal sign means assign value


#3

var understand = true;

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

still m getting err...its saying that "you dint print the string to the console"


#4

var understand = true;

while(understand==1 ){
console.log("I'm learning while loops!");
understand = false;
}
i got this one correct! srry...i dint read your text carefully.. thnx anyway it was hlpfull :slight_smile:


#5

1 is considered true, and zero is considered false. that is important to realize here. Actually i would do this:

understand == true

given understand contains a boolean value


#6

yea later i noticed it....dt true===1


#7