Im trying to call a function in a loop for different timeouts or delays.
for (var i = 0; i < 10; i++) {
callDelayedFunction(i);
}
function callDelayedFunction(i) {
setTimeout(function () {
console.log(i);
}, getRandomInt(1500, 4500) * i);
}
I expect
1,2,3,4,5,6,7,8,9
But I get
1,2,3,4,7,8,5,6,9
How can I solve this problems?