My issue is I am trying to increment the timeout time by the iteration value and time it by 1000. for example if the increment value is 5 it will be 5*1000 on the timeout.
I have tried various ways the first being ->
var textValue = 10;
function doSetTimeout(i) {
setTimeout(function() { console.log(i); }, i * 1000);
}
for(var i = 1; i <= textValue; i++){
doSetTimeout(i);
}
I also tried this ->
var textValue = 10;
for(var i = 1; i <= textValue; i++){
(function () {
var j = i;
setTimeout(function timer() {
console.log(j);
},j*1000);
})();
}
All I get on both is that the timeout is always set to 1000 ms even though the variable is being set correctly each time.
Any help would be appreciated.