I'm attempting to run a function X number of times, once per second.
I've tried to setTimeout within a loop, but instead of running once per second, it waits one second then runs 5 times.
Press.advance = function(distance) {
for (var i = 0; i < distance; i++) {
setTimeout(() => {
console.log('advancing') //want it to do this once per second
}, 1000)
}
}
How can I make it run once per second for distance
number of times?