Build a Simon Game - Feedback and Help

I’ve finished the user stories for Simon, but am still working on replicating the example’s functionality.

Notes: Right now my app is buggy largely due to my incorrect implementation of the main idle timer. If all the references to playTimer are coded out, the app works fairly well. Also, I’ve got it set up to win after the third round is completed. This is just for ease of testing.

Here is where I am stuck:

  1. The idle timer that fires a buzz sound if the player hasn’t moved for a few seconds. I’ve tried many strategies to place setTimeout and clearTimeout in different sections of code but every time I do this it seems to partially solve one problem while breaking other sections of code. The latest approach I took was to clear the timer from within the playTimer function (lines 180-197). This seemed logical to me that when the timer is running, if the player makes a move, the timer would be cleared. This doesn’t work though, and I’m having a hard time seeing why. In general, I’m just not seeing how to structure this section of code effectively. In general, I’m generating so many timers with successive calls, clearing and managing them is really unwieldy. At one point I was trying to just push all my timers to an array and clear them all with a loop, but I didn’t have success with that approach either.
  2. Getting the UI to work bug-free. Right now the game works if the player slowly gives input on their turn, but it gets buggy if the user starts quickly clicking input on their turn. You’ll see if you click fast many times on any given round the computer then plays an incorrect feedback sequence for that round. I tried doing some things by tracking the clicks, but I didn’t have much success there. I’m not sure how to give feedback each time the button is pressed, while also limiting the number of keypresses to the current round number (e.g., round 3 should only allow 3 keypresses.)

Here is my app. Thanks very much for any feedback and suggestions!