title: finding max of two numbers on button click
body: <p>I am pretty new to HTML and JavaScript, and am trying a homework task. </p>
  
  <p>There is a form with two fields where the user enters numbers, and a button. When the button is pressed, the max of the two numbers should be displayed.</p>
  
  <p>As it is, the output is NaN, but I don't know why. I have run it through the chrome debugger, and at the line <code>var1 = parseInt(var1);</code>, var1 has value NaN. The same happens on the next line. </p>
  
  <p>If I replace each line with something like <code>var1 = parseInt("6");</code>, this doesn't happen and everything behaves as expected (although obviously not doing what I need).</p>
  
  <p>Any idea what I'm doing wrong?</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt; Question 2 &lt;/title&gt;
    &lt;script&gt;
    function larger(var1,var2) {
      var1 = parseInt(var1);
      var2 = parseInt(var2);
      var max = var1&gt;var2 ? var1 : var2;
      return max;
      }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form&gt;
          &lt;label&gt;First number:&lt;/label&gt; &lt;input type="text" name="num1"/&gt;&lt;br/&gt;
          &lt;label&gt;Second number:&lt;/label&gt; &lt;input type="text" name="num2"/&gt;&lt;br/&gt;
          &lt;input type="button" value="Compute" onclick="myResult.value=larger(num1,num2)"/&gt;
          &lt;input type="text" name="result" id="myResult"/&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>