Simon game doing two turns at once

Simon game doing two turns at once
0

#1

My stupid simon game after you do a couple correct turns starts doing things twice. Example, It highlights buttons twice and adds two new buttons to the pattern array.

Open up the console to view the contents of arrays easily.

Can someone point out why this is happening?


#2

How do you start the game?


#3

It starts when you refresh the page. I have’nt added a start button yet so just f5.


#4

Didn’t look very close at your solution, so i may be missing something, but i think the problem lies in checkPattern func. At the begginning you have for loop, which ends after “if (userPattern.length == pattern.length)”. For each iteration the loop calls nextButton and showPattern with 1500ms delay. As the pattern array gets longer, the problem becomes visible.


#5

I see what you are saying, thank you! I will work on it