Problem with the Simon's game, showing multiple boxes

Hi, I’m trying to show the user the current state of the game.
But for some reason, all the elements are getting classed at a time without any delay. I’m confused.

Take the delay += 500 out of the setTimeout callback.

Currently the forEach is run and loops through all the items. But the delay is only incremented after the initial delay (100 ms) when the forEach already finished looping through all the items (and already “scheduled” the callback functions with the initial delay).

1 Like