title: Making a Simon Game, can't figure out what is wrong
body: <p>I am trying to make a Simon game, where the user follows an increasing sequence of randomly generated patterns and I almost finished it.</p>
  <p>But I have this problem, at times that appear random the function nextSequence() seems to stop working, which ruins the game, because you are unable to see the next color you have to click on.</p>
  <p>I have spend a lot of time trying to figure what is wrong but I just can't figure it out, usually it stops working correctly around level 5.</p>
  <p>This is the function:</p>
  <pre><code>function nextSequence() {
    userClickPattern = [];
  
    level++;
    $(&quot;h1&quot;).text(&quot;Level &quot; + level);
  
    let random = Math.floor(Math.random() * 5);
    let randomChosenColor = buttonColors[random];
    gamePattern.push(randomChosenColor);
  
    $(&quot;#&quot; + randomChosenColor)
      .fadeIn(100)
      .fadeOut(100)
      .fadeIn(100);
  
    makeSound(randomChosenColor);
  }
  </code></pre>
  <p>I don't really know if that is the problem but I haven't been able to pinpoint anything else.</p>
  <p>I'm pretty new in asking here and coding, if you need anything else or the question is unclear feel free to tell me how could I improve it.</p>
  <p>Here is the repository: <a href="https://github.com/IgnacioGR/SimonGame" rel="nofollow noreferrer">https://github.com/IgnacioGR/SimonGame</a></p>
  <p>Here is the page: <a href="https://ignaciogr.github.io/SimonGame/" rel="nofollow noreferrer">https://ignaciogr.github.io/SimonGame/</a></p>