title: Javascript Millionaire Calculator Loop
body: <p>I'm coding a calculator in Javascript that works out how long it will take someone to become a millionaire by calculating the following factors: Monthly Deposit and Return on Investment. To figure this out I need an Amortization schedule so that the interest is added onto the savings each month.
  See code:</p>
  
  <pre><code>    &lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
  function computeMillion(){
      var deposit = document.getElementById('deposit').value;
      var interest = document.getElementById('return').value;
      var amount = document.getElementById('amount').value;
  
      for(var i = 0; i &lt; 5; i++)
          {
              interestPayment = deposit * interest;
              principalPayment = deposit - interestPayment;
              principal -= principalPayment;
          }
      var months = amount / principal;
      document.getElementById('months').innerHTML = "Months to Millionaire ="+months;     
  
  }
  &lt;/script&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;p&gt;Amount Desired: £&lt;input id="amount" type="number" value="1000000" onChange="computeMillion()"&gt;&lt;/p&gt;
  &lt;p&gt;Monthly Deposit: £&lt;input id="deposit" type="number" onChange="computeMillion()"&gt;&lt;/p&gt;
  &lt;p&gt;Return on Investment: &lt;input id="interest" type="number" onChange="computeMillion()"&gt;%&lt;/p&gt;
  
  &lt;h2 id="months"&gt;&lt;/h2&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>So if a deposit of £50 was made initially, after that first month the savings should be £52.50 because of the interest of 5% that the user would input, the following month another £50 would be saved meaning that there is £102.50 in the account and then interest is added onto that which woudl equal £107.62 and so on.</p>
  
  <p>Can anyone see the code that isn't working? I can enter the amounts required but I get no results show up at all.</p>
  
  <p>Can anyone help?</p>
  
  <p>Thanks</p>