[HELP] Simon Game Help

Hello friends, my simon game seems to have trouble properly registering the player’s clicks. It doesn’t wait for the user to finish inputting the sequence before it checks to see if it matches the game’s sequence. I’ve researched and researched but I can’t seem to find the solution. Any assistance is greatly a appreciated.

It looks like there are several problems, but I will start you out with this:

function checkScore(x) {    // what is the purpose of the x parameter?
    if (...) { // problem          
        console.log("wrong");
        console.log(SimonGame.correctOrder)
        console.log(SimonGame.playerOrder)
      } else {          
          console.log("right");
          nextRound();
      }    
};

Think through your if statement:

SimonGame.playerOrder[SimonGame.playerOrder.length-1] !== SimonGame.correctOrder[SimonGame.playerOrder.length-1]

If the player order does not equal the correct order they are wrong. Else they are right and we move on to next round.

Problem: If the player has the first button correct, regardless of how many buttons there are left in the array, we immediately move on to nextRound()

Solution: Loop through the array, and if there is a problem, they fail. After checking through the entire array, and everything is correct, we can move on to next round.

Bonus Tip 1: It would also help to add some delay after the user presses the button and before we check and possibly go on to the next round.

Bonus Tip 2: Your code is a holy mess. Try formatting for once :wink:

Final Tip: Export your codepen (you can find this on the bottom right). Open it up in your browser, and go to developer tools > source > and your js file. Put some breakpoints in, it will help you find out whats going on.
Confused? Check this out: https://www.freecodecamp.com/videos/chrome-dev-tools-sources