It Runs But Only Once


#1

//Remember to set your condition outside the loop!
var count = 0;
var loop = function(){
while(count <= 3){
console.log("I'm looping");
counter++;
}
};

loop();

It loops once then I get an error.


#2

Inside for loop you have undefined variable counter. Instead of counter++ should be count++. So now with every iteration we add 1 to count while count will be equal to 3.


#3

Thank you very much!


#4

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