Lesson 10. Why does this work?


var getToDaChoppa = function(){
var yes = false
}while (yes === true){
console.log("it's true! switching to false");
yes = false;



Why does the while loop run when yes isn't true? (I used === just to make sure)


It ran only once. It will always run only once, regardless of condition state (true or false). It ran once, and your condition was false. It was expected.
I think that your messages in this code got you confused. You should do your code in do part of the loop, by doing it in while you're just confusing yourself. The code wont run if the condition is false, however if you can "trick" it to do something that is not usually done.


Ah I see now. Thanks for the speedy reply @igorcaletacar