title: Javascript function not working in browsers(but working fine in code snippet)
body: <p>I'm practicing straight from the MDN but for some reason this code isn't running in Chrome or IE. When you click the button, the function is not being called. It's a program that guesses the user input and says if it's right or wrong. Can someone please tell me what I did wrong? If you run this in code snippet it works perfectly fine. But for some reason it's not working properly in the browser.</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-js lang-js prettyprint-override"><code>var randomNumber = Math.floor(Math.random() * 100) + 1;
  
  var guesses = document.querySelector(".guesses");
  var lastResult = document.querySelector(".lastResult");
  var lowOrHi = document.querySelector(".lowOrHi");
  
  var guessSubmit = document.querySelector(".guessSubmit");
  var guessField = document.querySelector(".guessField");
  
  var guessCount = 1;
  var resetButton;
  
  
  function checkGuess() {
  
    var userGuess = Number(guessField.value);
    if(guessCount === 1) {
      guesses.textContent = 'Previous guesses: ';
    }
    guesses.textContent += userGuess + ' ';
   
    if(userGuess === randomNumber) {
      lastResult.textContent = 'Congratulations! You got it right!';
      lastResult.style.backgroundColor = 'green';
      lowOrHi.textContent = '';
      setGameOver();
    } else if(guessCount === 10) {
      lastResult.textContent = '!!!GAME OVER!!!';
      setGameOver();
    } else {
      lastResult.textContent = "Wrong!";
      lastResult.style.backgroundColor = 'red';
      if(userGuess &lt; randomNumber) {
        lowOrHi.textContent = 'Last guess was too low!';
      } else if(userGuess &gt; randomNumber) {
        lowOrHi.textContent = 'Last guess was too high!';
      }
    }
   
    guessCount++;
    guessField.value = '';
    guessField.focus();
  }
  
  guessSubmit.addEventListener('click', checkGuess);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;p class="guesses"&gt; &lt;/p&gt;
   &lt;p class="lastResult"&gt;&lt;/p&gt;
   &lt;p class="lowOrHi"&gt;&lt;/p&gt;
  
   &lt;label for="guessField"&gt; Enter a guess: &lt;/label&gt; &lt;input type="text" id="guessField" class="guessField"&gt;
  
   &lt;input type="submit" value="Submit guess" class="guessSubmit"&gt;</code></pre>
  </div>
  </div>
  </p>