Add contribution code

This commit is contained in:
= 2017-12-13 22:30:12 -07:00
parent 88f2e13e72
commit 9b233fab7b
1 changed files with 8 additions and 5 deletions

View File

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