How can I add a delay inside each iteration of an _.each loop to space out the calling of an interior function by 1 second?
_.each(this.rows, function (row, i) {
row.setChars(msg[i] ? msg[i] : ' ');
});
You don't need extra IIFE
_.each(this.rows, function (row, i) {
setTimeout(function () {
row.setChars(msg[i] ? msg[i] : ' ');
}, 1000 * i);
});
since you're not doing it in an explicit for
loop.
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