Simon game doing two turns at once

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?

How do you start the game?

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

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.

1 Like

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