I'm confused


When I wrote the myCondition = false within the last { } it crashed:

var myCondition = true

var getToDaChoppa = function(){
    do {console.log("RAAAAAUN!")}
**myCondition = false** //it is currently outside the {} and did not crash //


But when I wrote the myCondition = false within the {} of the code below it didn't crash. In fact, it crashed when I wrote it outside the {}; . Why is this happening?

var condition = true

var soloLoop = function(){
    while(condition) {
        console.log("Looped once!");
    **condition = false**;}   



Ok @codeninja46066 your confusing you self here.. First you said :

Then you said..:

Which one of these are true? Plus please take a look at this. It will help.


Thanks for the link! I cleared up my phrasing.

My second statement is referring to the code below it.


It crashed when you wrote it outside since it wont get to it. In a while loop it only executes whats inside the while loop brackets. But when you wrote it inside it ran 2 times , because it was set to false, And in a do-while loop it runs then checks for the conditon? Was this clear?