for (i = 1; i <= 5; ++i) { setDelay(i); }
function setDelay(i) { setTimeout(function(){ console.log(i); }, 1000 * i); }
This frustrated me, in my case I needed the '* i' as shown above. Hope this helps anyone else suffering the same problem!
for (i = 1; i <= 5; ++i) {
setDelay(i);
}
function setDelay(i) {
setTimeout(function(){
console.log(i);
}, 1000 * i);
}
This frustrated me, in my case I needed the '* i' as shown above. Hope this helps anyone else suffering the same problem!