title: How Do I Make My Game Work? ELI5
body: <p>I'm trying to make a game that displays a sequence of images depending on the number the user puts in a input box. I want it to show a random image from an array of my images for however many times the user set it to show it.</p>
  
  <p>Here's my JavaScript:</p>
  
  <pre><code>var numLeaves = 0;
  var numSeq = ["1.jpg","2.png","3.jpg","4.jpg","5.png","6.jpg","7.jpg","8.jpg","9.jpg","0.jpg"];
  
  function startGame() {
  
    while (1 &lt; 10) {
      randomNum = Math.floor((Math.random() * numSeq.length));
  
      if (randomNum === 0) {
        numLeaves = 1;
      } else if (randomNum == 1) {
        numLeaves = 2;
      } else if (randomNum == 2) {
        numLeaves = 3;
      } else if (randomNum == 3) {
        numLeaves = 4;
      } else if (randomNum == 4) {
        numLeaves = 5;
      } else if (randomNum == 5) {
        numLeaves = 6;
      } else if (randomNum == 6) {
        numLeaves = 7;
      } else if (randomNum == 7) {
        numLeaves = 8;
      } else if (randomNum == 8) {
        numLeaves = 9;
      } else if (randomNum == 9) {
        numLeaves = 0;
      }
  
      document.getElementById("picture").src = numSeq[randomNum];
      setInterval(function(){document.getElementById("picture").src = ""}, 1500);
      i++;
    }
  
  
  }
  
  function submitInput() {
    if (document.getElementById("leaveGuess").value == numLeaves) {
      document.getElementById("result").innerHTML = "Correct!";
    }
    else
    {
      document.getElementById("result").innerHTML = "Incorrect... There were " + numLeaves + " leaves on the shamrock";
    }
  
  }
  </code></pre>
  
  <p>And here's my HTML:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  
    &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="rep.css"&gt;
      &lt;script type="text/javascript" src="rep.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
  
  
    &lt;body&gt;
      &lt;div id="test"&gt;&lt;/div&gt;
  
      &lt;div id="content"&gt;
  
        &lt;div id="title" class="center"&gt;
          &lt;h1&gt;Repetitive&lt;/h1&gt;
          &lt;p&gt;Created by Daniel Hancock&lt;/p&gt;
          &lt;h2&gt;Instructions:&lt;/h2&gt;
          &lt;p&gt;In under one second memorize the amount of leaves on the shamrock. &lt;br&gt; After one second, you will be asked to enter the number of leaves that you saw on the shamrock.&lt;/p&gt;
          &lt;label for="numSequence"&gt;&lt;strong&gt;Length:&lt;/strong&gt;&lt;/label&gt;
          &lt;input id="numSequence"&gt; &lt;br&gt;
          &lt;button onclick="startGame()" id="startButton"&gt;New&lt;/button&gt;
        &lt;/div&gt;
  
        &lt;div id="display" class="center"&gt;
          &lt;img src="" id="picture" width="215" height="215"&gt;
          &lt;div id="guessing" class="center"&gt;
            &lt;input id="leaveGuess"&gt;
            &lt;button onclick="submitInput()"&gt;Submit&lt;/button&gt;
            &lt;p id="result"&gt;&lt;/p&gt;
          &lt;/div&gt;
        &lt;/div&gt;
  
      &lt;/div&gt;
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>Explain it to me like I'm a five year old.</p>