title: Should I use an array instead of a random number generator here?
body: <p>I am making a memory game using Javascript, HTML, and CSS.</p>
  <p>Here is a brief description of the game:</p>
  <ul>
  <li>The program generates a random number, which is shown on
  screen.</li>
  <li>After about 5 seconds, the number disappears and a pop-up box appears on the screen, asking for the user to enter the number he or she just saw.</li>
  <li>If the number matches the one that was previously on screen, then an alert box with the word &quot;Correct&quot; appears. If not, an alert box with the text &quot;Nope. Nice try&quot; appears.</li>
  </ul>
  <p><strong>Here's my problem:</strong>
  The alert box says &quot;Nope. Nice try&quot; even when I enter the correct number.</p>
  <p>Here is what I've coded thus far:
  (Keep in mind that I have yet to any implement setInterval/setTimeout functions. I made the &quot;hide&quot; function manual for convenience.)</p>
  <p>JS:</p>
  <pre><code>/* game level = easy 
  
  numbers from 1-9000 are generated */
  
  function random(a){
      a = Math.floor(Math.random() * (9000 - 1) + 1);
      
      document.getElementById(&quot;screen&quot;).innerText = a;
  }
  
  function getInput(a){
      var input = window.prompt(&quot;Enter the number you just saw:&quot;);
      
      if(input === a){
          alert(&quot;Correct!&quot;);
      }
      else{
          alert(&quot;Nope. Nice try.&quot;);
      }
  }
  
  /* hide toggle */
  
  function hide() {
    var x = document.getElementById(&quot;screen&quot;);
    if (x.style.display === &quot;none&quot;) {
      x.style.display = &quot;none&quot;;
    } else {
      x.style.display = &quot;none&quot;;
    }
  } 
  </code></pre>
  <p><strong>My question: Would it be ideal to use an array of numbers from 1-9000 instead?</strong></p>
  <p>With an array, I figure I can do something like this:</p>
  <pre><code>for(var i = 0; i &lt; arr.length; i++){
     if(//){
    }
    else{
    }
  }
  </code></pre>
  <p>Thank you for reading.</p>