To learn it, you gotta 'do' it Crash


#1


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

My browser crashes here and I can't figure out why? I imagine the logic goes like this:
1. declare getToDaChoppa function
2. initialize trueVar boolean variable with true value
3. begin do{ }, printing "in do" to console
4. begin while(){} on trueVar === true condition
5. assign false to trueVar
6. print "in while" to console
7. trueVar is now false, so while should not be executed.
8. exit while
9. exit function

Am I blind? Please help. I can't progress


var getToDaChoppa = function(){
    
    var trueVar = true;
    
    do{
        console.log("in do");
    } 
    
    while (trueVar){
        trueVar = false;
        console.log("in while");
    };
    
};

getToDaChoppa();


#2

we have two types of while loops, do while loop:

do {
    // loop content
} while (condition)

and a while loop:

while (condition){
    // loop content
}

you seemed to have combined do while and while loop into a do while while loop, you can't do this


#3

Thanks for the help. I deserve a kicking for not paying attention to the syntax.
Amended to :

var getToDaChoppa = function(){

var trueVar = true;

do{
    console.log("in do");
    trueVar = false;
} 
while (trueVar)

};

getToDaChoppa();

and it works now. Thanks again


#4