So close yet so far away... Just need 1 more function to work to finish the Simon Game


#1

Hi everyone

So im extremely close to finishing my simon game (and by extension the front end certificate) but I just need 1 more function to make the game work properly.

On line 59 I need to make a function to waits for the users turn, that waits (or counts) for them to click the full sequence and returns either true or false if the sequence of buttons they clicked was right or not. I cant manage to get it to wait for more than 1 button click or stop mid way through if they clicked something incorrect. This function is run each time a color button (green, red, blue or yellow) is clicked then the true or false is put into a different (working) function to carry on with the rest of the game.

In this code, aiAnswers is the array of colors that need to be compared e.g [“red”, "red, “green”, “blue”] ect.

Really appreciate any ideas or advice anyone could give.


#2

I’m a beginner too, and just finished this challenge.
For my part:

  1. I create an array which contain the computer moves. eg: roundset = [“red”,“red”,“blue”,“green”];
  2. I create an empty array which contains the moves of the player. Called it playset
  3. By each click, player will insert his move into the playset. Then I will compare the last move of playset, with the move in roundset which has the same index (i used .indexOf() for this).
    => if false: reset the array to empty.
    => if true: comepare playset.length and roundset.length.
    =======> if true: continue to next round.
    =======> if false: do nothing.

That’s my noobish solution. Hope it can help! ;D


#3

I used this basic idea to finally get it working after nearly a week, thanks for your help.