Hi all,
I’m working on my Simon Game and am having some trouble setting a delay between each simon sequence.
I’m wondering, how do you set a delay between each iteration within a forEach loop?
I have tried a million different things with setTimeout and setInterval, but just having no luck!!!
The code in question is as follows:
function computerClick() {
let computerSequence = gameConfig.moves.computer;
let maxRounds = gameConfig.round,
roundCount = 0;
(function next() {
if (roundCount++ >= maxRounds) return;
setTimeout(() => {
computerSequence.forEach((tile, index) => {
buzz(computerSequence[index]);
console.log("length", gameConfig.round);
});
next();
}, 800);
})();
}
The full pen is here => http://codepen.io/JackEdwardLyons/pen/PWvQBN