Review - While loops issue


Hi Guys, in the review section of Introduction to While loops I entered this for my "while" loop:

var name = true

    console.log("JUST DO IT");
    name = false;

However it seems to cause an infinite loop, once I cut it out the others process fine, I thought It was my syntax so I revisited the exercise but I found this:

var hungry = true

console.log("I'm no longer hungry.");
hungry = false;

and when I paste it in it works perfectly, as far as I can see they are identical, I've been sstaring at this for sometime, can anyone shed some light on this?


Not sure if it's the issue, as they do indeed seem identical, but you should definitely add a semicolon in your variable declaration in both codebits:
var name = true;
Can't see anything else should be wrong.


Check in the instructions if they want to print some string different from "JUST DO IT".

Other problem can be that name is reserved word in javaScript.


Well there definitely isn't another string to include as this section's instruction is just to write a "for" loop, a "while" loop and a "do". But I think you could be correct with Name being reserved! Thank you, I'll go search that! ^^

Also thank you for the input Nissen!


Name is not an official keyword but it seems to be an attribute of all DOM objects which has the ability to always be a string no matter what you assign to it. And non-empty strings in conditions tend to be truthy as you can read here:
So even if you change the value to false it still stays an infinite loop. Just pick another name and it should work.