10. To learn it, you gotta 'do' it - infinite loop


#1



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


The code loops infinitely. What's wrong?


var time = 0

var getToDaChoppa = function(x) {
    time = x;
    do {
        console.log( "Get to da choppa, nau!" );
    }
    while( time > 0 )  {
        console.log( "Getting to the chopper in "+ time +"..." );
        time = time - 1;
    };
};

getToDaChoppa(3);


#2

HI the do while have that structure..

do {
    #Do something;
} while(condition);

and the while statement

while(condition) {
   #do something
   #inscrement or stop the loop
}

But you can't combine them


#3

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