Simon Game button help


Working through my Simon Game project, how am I able to get the program to randomly press buttons once I hit “Start”? Basically I want to be able to see the buttons being pressed in sequence instead of just hearing the sounds.


I did it with setTimeout and adding a CSS class that is brighter that gets removed after ‘ms’ milliseconds, that creates a flashing effect. If you use setTimeout, you have to do it recursively though, since you can’t loop that function.

let audio = new Audio(sounds[color]);;
time_id = setTimeout(function() {
}, ms);`