I'm trying to log the change of a value in the console (Firefox/Firefly, mac).
if(count < 1000)
{
count = count+1;
console.log(count);
setTimeout("startProgress", 1000);
}
This is only returning the value 1. It stops after that.
Am I doing something wrong or is there something else affecting this?
You don't have a loop. Only a conditional statement. Use while
.
var count = 1;
while( count < 1000 ) {
count = count+1;
console.log(count);
setTimeout("startProgress", 1000); // you really want to do this 1000 times?
}
Better:
var count = 1;
setTimeout(startProgress,1000); // I'm guessing this is where you want this
while( count < 1000 ) {
console.log( count++ );
}
I think you are looking for while
loop there:
var count = 0;
while(count < 1000) {
count++;
console.log(count);
setTimeout("startProgress", 1000);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With