Add contribution code
This commit is contained in:
parent
88f2e13e72
commit
9b233fab7b
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)
|
||||
}
|
||||
console.log("Test")
|
||||
var final = +final + +contribution
|
||||
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…
Reference in New Issue