I am stuck at making the Simon game.
For easily observing when the colours are blinked, I have made blinking action in such a way that the original colour is replaced by black (will replace it with appropriate colors later). I use jQuery to add and remove a class (color-active) to represent blinking(using functions runSequence and stripClass).
The problem is this, after the first iteration of the game(when only one colour is bliked), for the subsequent iterations, all the colours are blinked simultaneously. I figured out this problem has to do with setTimeout() being asynchronous, So , setTimeout doesn’t block the execution of the subsequent steps (i.e. the code is not executed sequentially). Even after searching through the recommended solutions (on Stack Overflow) I have not been able to understand and implement them. How can I get around this?