title: Calculating Volume using a function in Javascript
body: <p>I'm relatively new to Javascript and for one of my assignments at school I was asked to calculate the volume of a rectangular prism using 3 input boxes and a 4th one to display the volume. I made a function and defined my variables and gave each input box an id, when I input the numbers and run it through the function I made I keep getting NaN. What exactly is triggering this?</p>
  
  <pre><code>    &lt;!doctype html&gt;
  
      &lt;html&gt;
      &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;Surface Area &amp;amp; Volume&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="stylesheet.css"&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
      &lt;script&gt;
      "use strict";
      var $ = function(id) {
          return document.getElementById(id);
      };
  
      var length = $("length");
      var width = $("width");
      var height = $("height");
      var amountVolume = 0;
      function calculateVolume(length, width, height) {
          amountVolume = parseFloat(length) * parseFloat(width) * 
      parseFloat(height);
      var volumeRound = amountVolume.toFixed(2);
          $('volume').value = volumeRound;
      };
  
  
      &lt;/script&gt;
      &lt;div id="wrapper"&gt;
      &lt;form&gt;
      &lt;h1&gt;Surface Area &amp; Volume&lt;/h1&gt;
  
      &lt;p&gt;Length:
  
      &lt;input type="text" id="length" value="0"/&gt;
  
      &lt;/p&gt;
      &lt;br /&gt;
      &lt;p&gt;Width:
  
          &lt;input type="text" id="width" value="0"/&gt;
  
      &lt;/p&gt;
      &lt;br /&gt;
      &lt;p&gt;Height:
  
          &lt;input type="text" id="height" value="0"/&gt;
  
      &lt;/p&gt;
      &lt;br /&gt;
      &lt;p class="change"&gt;Surface Area:
  
          &lt;input type="text" id="area" disabled="disabled" /&gt;
      &lt;/p&gt;
      &lt;br /&gt;
      &lt;p class="volume"&gt;Volume:
  
          &lt;input type="text" id="volume" disabled="disabled" /&gt;
      &lt;/p&gt;
      &lt;br /&gt;
      &lt;input type="button" id="calculate" onClick="calculateVolume(length.value, width.value, height.value)" value="Calculate Volume"/&gt;
     &lt;/form&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>