all:
I have this loop in which I have a timeout in to try and pause an iteration while an animation and sound finish before it moves on to the next iteration, however; I'm finding that i is not increased when it hits the timeout anonymous function and causes an infinite loop. Here is the code:
var i = 0;
while (i < gamePattern.length - 1) {
console.log(i);
buttonAnimation(gamePattern[i]);
buttonSound(gamePattern[i]);
setTimeout(() => {
i++;
}, 400);
}
I was thinking of trying to set it up with promises, but I don't feel that would actually pause the iteration like I though. Any thoughts or ideas would be greatly appreciated.
Thank you,
Kevin