Simon game help needed pls

It’s the first time I am posting on here and that is because I am really stuck with the last project.

I am struggling with a click function and an array comparison to evaluate the clicked array vs the computers array.

I would appreciate any help and guidance towards making some progress and finishing my project.

Thanks in advance fellow campers.

You can compare it, only with an array like this

var arrayOfSteps = [0, 1, 1, 3, 0];
var currentStep = 3;
function buttonClicked(button) {
  var expect = arrayOfSteps[currentStep];
  var actual = button.number;
  if (actual === expect) {
    currentStep++; //continue
  } else {
    errorSound();
    if (strict) 
      return restartGame();
    else 
      return repeatSteps();
  }
  var gotAllSteps = currentStep === arrayOfSteps.length;
  if (gotAllSteps) {
    addNewStep();
    animateMachineSteps();
  }
}

this is not a real solution, it’s a sort of pseudocode to see how you could solve it.

your problem with a click function, could you be more specific?.

any questions?

see that you can add an “if” in gotAllSteps to check if the player won

Thank you very much for your time in constructing an answer, my code works now and it was exactly the help I needed to proceed with my project, Sorry for being a little bit vague in my description stating the problem. I took some time to try and understand your code and I now see where my mistake was.

1 Like

You welcome.

I don’t think you describe it wrong, is just I’m not very good with English at the moment.

Great work!