Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
  <head>
    <meta charset="ISO-8859-1">
    <title>Interest Calculator</title>
  </head>
  <body>
    <fieldset>
      <legend>Interest Calculator</legend>
      Enter amount: <input type="text" id="amount" ><br><br>
      Interest rate: <input type="text" id="interest"><br><br>
      Enter years: <input type="text" id="years"><br><br>
      <button onclick="calculate()">Calculate</button>
    </fieldset>
    <p id="sum"></p>
    <script>
      function calculate(){
        var amount = document.getElementById("amount").value;
        var rate = document.getElementById("interest").value;
        var years = document.getElementById("years").value;
        var sum = amount*(1+rate)^years;
        var message = "Your total return will be: " + sum;
        document.getElementById("sum").innerHTML = message;
      }
    </script>
  </body>
</html>
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers