11. Review, I am missing something


#1



Lesson 7 - Intro to 'While' loops. Exercise 11 - Review.


Once I submit the code the following happens:

There is a delay before an error generates. However, in the right window it does print "Initiating launch sequence." once before the error appears on screen with this message:

"A script on this page may be busy, or it may have stopped responding. You can stop the script now, open the script in the debugger, or let the script continue."

Script: https://www.codecademy.com/assets/repl.html line 1 > eval:10


var initiate = function() {
    var bool = false;
    do {
        console.log("Initiating launch sequence.");
    } while(bool);
}
initiate();

var count = 0;
while(count <= 3); {    
    console.log(".");
    count++;
}

for(var i = 10; i >= 0; i--) {
    console.log(i);
}


#2

This might be the problem. Have a look at this for an explanation why semicolons after conditions are a problem:


The link is about if/else conditions but the logic applies for loops as well. The infinite loop is:

var count = 0;
while(count <= 3);

count is 0
check if count is less than or equal to 3 -> it is
execute statement: Which is just the semicolon ;
check if count is less than or equal to 3 -> it is
execute statement: Which is just the semicolon ;
check if count is less than or equal to 3 -> it is
execute statement: Which is just the semicolon ;
...


#3

Thank you very much!


#4

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