I have written a for
loop using setInterval
. The intention was to "drip feed" the output of the for loop to the user. So basically I would like to send the console.log
message every 10000ms
and output it on the console of the user.
See my example below:
function longForLoop(limit) {
for (var i = 0; i < limit; i++) {
setInterval(() => {
console.log("This is a long for loop. We are at " + i)
}, 10000)
}
}
longForLoop(10)
However, I only get the full result back as a whole?
Any suggestions what I am doing wrong here?
Appreciate your replies!