title: Why is the number randomNumber function running when I enter a number into the box and select Guess
body: <p>I am working on a homework assignment to create a hot/cold app but have become stuck on the submit (Guess) button. I wrote a function called newGame so when you select New Game the randomNumberGenerator function will run. But it appears that it is also running if you enter a number into the input box and choose the Guess button but I am not sure why. Here is my script below, as well as a link to a js fiddle with the entire code:</p>
  
  <pre><code>$(document).ready(function(){
  
  var randomNumber = 0;
  var userGuess = 0;
  var guessCount = 0;
  
  //generates number
  function randomNumberGenerator() {
      randomNumber = Math.floor(Math.floor(Math.random()*100));
      console.log("random number= " + randomNumber);
  }
  
  randomNumberGenerator();
  //starts new game
  function newGame(){
      guessCount = 0;
      randomNumber = (Math.floor(Math.random()*100));
      console.log("new number is " + randomNumber);
  }
  
  function compareGuess(){
      if (userGuess == randomNumber) {
      $('#feedack').text('correct');
      }
  }
  
  //submit
  $('#guessButton').click(function() {
      compareGuess();
  });
  
  //click for new game
  $( ".new" ).click(function() {
  newGame();
  });
  
  
  });
  </code></pre>
  
  <p><a href="https://jsfiddle.net/w8jxqjem/1/" rel="nofollow">https://jsfiddle.net/w8jxqjem/1/</a></p>
  
  <p>Thank you for your help, I am a beginner. Please let me know if there is any other information that I can provide.</p>