title: Using RNG in comparison only returns the Else variable
body: <p>So trying to make a Higher or lower game (1st javascript project)</p>
  
  <p>I run into a snag when I try and use a random generated number in the comparison.</p>
  
  <pre><code> &lt;html&gt;
   &lt;body&gt;
  
   &lt;p id="rngout"&gt;&lt;/p&gt;
   &lt;input type="number" id="a"&gt;
   &lt;input type="number" id="b"&gt;
   &lt;p id="comparison"&gt;&lt;/p&gt;
  
  
   &lt;button id="submit"&gt;Compare&lt;/button&gt;
  
   &lt;script&gt;
  
   window.onload = function() {
   document.getElementById("rngout").innerHTML = Math.floor(Math.random() * 10 + 1 );;
   }
  
   document.getElementById('submit').onclick = compare;
  
   function compare() {
  
   var a = document.getElementById('a').value;
   a = parseFloat(a);
  
   var b = document.getElementById('b').value;
   b = parseFloat(b);
  
   var comparison;
  
   if(a &gt; b) {
   comparison = '&gt;';
   } else if(a &lt; b) {
   comparison = '&lt;';
   } else {
   comparison = '=';
   }
  
   document.getElementById('comparison').innerHTML = comparison;
  
   }
   &lt;/script&gt;
  
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p>What I want is to use the output of the window.onload function - what goes into id="rngout" to be used in the comparison below. If I use 2 user inputs (currently how it is) then it works.</p>
  
  <p>Be gentle, its my first time!</p>