title: Javascript Psychic Game
body: <p>I am creating a guessing game and am trying to get a condition that doesn't allow my user to choose the same answer twice.  I was thinking somehow say if the userGuess is not equal to an item in the empty span (user guesses) I created then nothing happens.  Am new to javascript and just needed some direction!  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en-us"&gt;
  &lt;head&gt;
   &lt;meta charset="utf-8"&gt;
   &lt;title&gt;Psychic Game&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
   &lt;div id="game"&gt;
    &lt;h1&gt; The Psychic Game &lt;/h1&gt;
    &lt;p&gt;Guess what letter I'm thinking of!&lt;/p&gt;
    &lt;p&gt;Wins:&lt;/p&gt;
    &lt;p&gt;Losses:&lt;/p&gt;
    &lt;p&gt;Guesses Left:&lt;/p&gt;
    &lt;p&gt;Your Guesses so far:&lt;/p&gt;
   &lt;/div&gt;
  
   &lt;script type="text/javascript"&gt;
    
     var computerChoices = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",];
  
     var wins = 0;
     var losses = 0;
     var numGuesses = 9;
     var guessChoices = [];
  
     document.onkeyup = function(event) {
  
      var userGuess = event.key;
  
      var computerGuess = computerChoices[Math.floor(Math.random() * computerChoices.length)];
  
      var options = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",];
      
  
     if (options.indexOf(userGuess) &gt; -1) {
  
      if (userGuess === computerGuess) {
       wins++;
       numGuesses = 9;
       guessChoices = [];
      }
  
      if (userGuess != computerGuess) {
       numGuesses --;
       guessChoices.push(userGuess);
      }
  
      if (numGuesses === 0) {
  
      numGuesses = 9;
      losses ++;
      guessChoices = [];
  
      
     }
  
     var html = 
     "&lt;h1&gt; The Psychic Game &lt;/h1&gt;" +
     "&lt;p&gt;Guess what letter I'm thinking of!&lt;/p&gt;" +
     "&lt;p&gt;Wins: " + wins + "&lt;/p&gt;" +
     "&lt;p&gt;Losses: " + losses + "&lt;/p&gt;" +
     "&lt;p&gt;Guesses Left: " + numGuesses + "&lt;/p&gt;" +
     "&lt;p&gt;Your Guesses so far: " + guessChoices.join(", ") + "&lt;/p&gt;";
  
     document.querySelector("#game").innerHTML = html;
  
     
     }
    };
  
   &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>