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 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(final)
|
||||||
}
|
}
|
||||||
console.log("Test")
|
//console.log("Test")
|
||||||
console.log(final)
|
//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;
|
||||||
|
|
Loading…
Reference in New Issue