title: How can I compare a set of numbers to find out which one is closer to the generated one?
body: <p>I am making a game where two players enter a number and then the computer randomly generates a number between 1 and 10.</p>
  
  <p>example:</p>
  
  <pre><code>var number1 = prompt("player1 enter number here");
  var number2 = prompt("player2 enter number here");
  var randomNumber = Math.floor(Math.random() * (10 - 1 + 1)) + 1;
  </code></pre>
  
  <p>I can't figure out how I am going to compare both numbers to the generated one and have the computer decide which player has the closer number.</p>