'While' loops in JS can't figure this one out


#1


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


Oops, try again. It looks like you didn't print the string to the console. Check your loop syntax!


var understand = true;

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


#2

You have set the variable understand to be a boolean, but you're checking it as an int. This will return an error because they are different data types.

Try checking if understand is equal to true instead.


#3

Hi there. Your while condition testing is a little off.

The while loop will commence when the condition tested is true. At the moment we're saying.

Is understand (true) equal to 0 (false). Nope (false). Therefore we will not enter the while loop.

If instead you did

while(understand)

This would work because remember, while will run as long as the conditon in it's parentheses is true. In which case it is.


#4

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