11/11 stuck in infinite loop. Please help!


#1

My browser keeps crashing after I execute the code I've written down below. I even made sure to set the assigned variables false to prevent infinite loops but it's still not working. The for loop is fine and already tested, the while loop could be correct but I'm not 100% sure, and the do/while loop is probably the culprit. Can anyone help guide me to fixing this? Thanks in advance!


// Write your code below!
for(var num = 100; num > 0; num--){
console.log(num + "...");
if(num === 1){
console.log("BOOM!");
}
}

var count=10;
while(count < 100){
console.log("This loop was a success!");
count++;
}

var userAge = prompt("Enter age here:");
do{
console.log(userAge);
} while(userAge < 18){
console.log("You are ineligable.");
userAge = false;
}

EDIT: I fixed the issues. I added 'count++' in my while loop and removed some code and added an if statement in my do/while loop.


#2

This is your infinite loop:

var userAge = prompt("Enter age here:");
do{
    console.log(userAge);
} while(userAge < 18){
    console.log("You are ineligable.");
    userAge = false;
}

Perhaps try something like this:

var userAge = prompt("Enter age here:");
var shortBy = 0;
do{
    console.log(userAge);
    userAge++;
    shortBy++;
} while(userAge < 18)
if (shortBy > 0) {
    console.log("You are ineligable.");
    console.log("Age is short by " + shortBy + " years.");
    userAge = false;
}