Not sure how to do 5/13 without crashing the browser


#1

for (var i = 5; i < 50; i+ ) {
console.log(i);
}

Here's what I have. Anyone know what I must do to complete the exercise?


#2

You have used "i+" instead of "i++" or "i+=1". Everything else looks fine.


#3

It's i+=5 in the exercise but the idea is right, what you need to do is to increment the counter after each loop. If you don't then your loop will not be able to get finished and therefore runs on and on and on and console.log seems to be a command that takes some ressources when being executed so your browser cannot handle it executing it continiously forever.


#4

The best way to handle it is by using the break statement such that when the loop reaches 50 it breaks otherwise your browser will hang. check out the below code.
for (var i = 5; i < 51; i+=5) {
console.log(i);
if(i == 50){
break;
}
}


#5

That is what the second part of the for loop is for. If this part fails so the break case will :frowning: