Browse Source

Add contribution code

master
= 5 years ago
parent
commit
9b233fab7b
  1. 13
      calculate.js

13
calculate.js

@ -8,6 +8,7 @@ function calculate() {
var numReg = /^\d+$/;
var final = 0;
var i = 0;
var contribution = 0;
// Get user input
@ -28,18 +29,20 @@ function calculate() {
}
var rate = rate * 0.01
console.log(rate)
//console.log(rate)
var interest = amount * rate
console.log(interest)
//console.log(interest)
var final = amount;
for (i = 0; i < time; i++) {
var final = +final + (+final * +rate)
console.log(final)
var final = +final + +contribution
console.log(final)
}
console.log("Test")
console.log(final)
//console.log("Test")
//console.log(final)
var final = final.toFixed(2);
//Show result
alert("You final investment amount is $" + final);
document.getElementById("interest").innerHTML = "Your final investment amount is $" + final;

Loading…
Cancel
Save