title: Uncaught TypeError: Cannot read property 'toFixed' of undefined
body: <p>I know that others have had this error thrown but I think I have some sort of syntax problem that's causing this to happen for me. If you can find it I would be grateful. I'm new to JavaScript and have been staring at this simple program for an hour. </p>
  
  <p>Here's the JavaScript: </p>
  
  <pre><code>"use strict";
  var $ = function(id) {
      return document.getElementById(id);
  };
  
  var calculateFV = function(investmentAmount, interestRate, yearsAmount) {
      var futureValue;
  
      //get the future value after the amount of years entered
      for (var i = 1; i &lt;= yearsAmount; i++ ) {
          var interest = futureValue * interestRate / 100;
          futureValue = futureValue + interest;
      }
  
      return futureValue.toFixed(2);
  };
  
  var processEntries = function(investmentAmount, interestRate, yearsAmount) {
      var investment = investmentAmount;
      var interest = interestRate;
      var years = yearsAmount;
  
      var futureValue = calculateFV(investment, interest, years);
      $("calculate").value = futureValue;
  };
  
  window.onload = function() {
    $("calculate").onclick = processEntries;  
  };
  </code></pre>
  
  <p>And here's the HTML:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
   &lt;meta charset="UTF-8"&gt;
   &lt;title&gt;Future Value Calculator&lt;/title&gt;
   &lt;link rel="stylesheet" href="future_value.css"&gt;
   &lt;script src="future_value.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
   &lt;main&gt;
       &lt;h1&gt;Future Value Calculator&lt;/h1&gt;
  
       &lt;label for="investment"&gt;Total Investment:&lt;/label&gt;
       &lt;input type="text" id="investment"&gt;&lt;br&gt;
  
       &lt;label for="rate"&gt;Annual Interest Rate:&lt;/label&gt;
       &lt;input type="text" id="rate"&gt;%&lt;br&gt;
  
       &lt;label for="years"&gt;Number of Years:&lt;/label&gt;
       &lt;input type="text" id="years"&gt;&lt;br&gt;
  
       &lt;label for="future_value"&gt;Future Value:&lt;/label&gt;
       &lt;input type="text" id="future_value" disabled&gt;&lt;br&gt;
  
       &lt;label&gt;&amp;nbsp;&lt;/label&gt;
       &lt;input type="button" id="calculate" value="Calculate"&gt;&lt;br&gt;      
   &lt;/main&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  </code></pre>
  
  <p>Thanks so much!</p>