Need some suggestions! stuck in "Review"


#1


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


In the last challenge, I think there must be some problems in the "while".
I thought I can use just 1 variable to run it, but it seems that infinite loops happened.....

Why are the loops won't stop when the condition "i=5" ?


// Write your code below!
var i = 1;

for(i=1; i<3 ; i++){
    console.log("for loop x"+ i);
}
while(i < 5){
    console.log("while loop x"+ i)
    i ++;
}
do{
    console.log("last one loop!");
}while(i<8);


#2

Look at here........

you forget to increment i...

do{
    console.log("last one loop!");
    i++;
}while(i<8);

#3

Thanks for your reply!
But it still crashed........
I think maybe something is going wrong in "while" part....


#4

Paste your new code..


#5

Sure~
plz check it below:

var i = 1;

for(i=1; i<3 ; i++){
console.log("for loop x"+ i);
}
while(i < 5){
console.log("while loop x"+ i)
i ++;
}
do{
console.log("last one loop!");
i ++;
}while(i<8);


#6

try to refresh the page... Normally it works


#7

oh yes!!! it didn't crash!!!!

Thank you for your help!


#8

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