I Need Some Assistance With the Simon Game

I Need Some Assistance With the Simon Game


I’m working on the Simon project and the first round is working. But after that, it’s showing that it’s incorrect. Can someone please take a look and tell me what I’m missing?


Ok so a few things. First, the game is not waiting for the player to do all of the things. If you just press the first color in the sequence, it says ok and adds another color to the sequence. Also its adding to the array too many times. I click yellow and yellow is added to user input 3 times.

I think you should scrap this or most of it and plan a bit ahead.
For example, you know that every turn, the computer has to add a color to the sequence and play it. You got this part down, Its the getting userinput thats got you messed up.

I’ll give you a hint onclick="input(this);"
Add this to a button and when you click it, it will run function input() while passing itself as a parameter. Then you can get the id from the argument.

I dont want to give away the solution but just remember what you have to do and do it one step at a time.

  1. Generate a sequence and play it. Check

  2. Get user input and check if the input selected is correct. Hint: Use length of userinput - 0 as an index to compare input to the sequence array

  3. If its wrong, Visual indication and DONT add to userinput. Depending on if strict or not might have to restart

  4. Finally After every round, clear userinput. You were doing this but the way you got user input was flawed

Happy coding! and keep up the good work! :slight_smile: :+1:


Thank you so much. I added onclick=“checkInput(this);” to each of the color buttons and wrote a new checkInput function from scratch and it’s working now…so far. I haven’t tested all 20 rounds yet, but thanks for the hint. :slight_smile:
There are still some stuff I gotta work on, but adding onclick to each button made all the difference.