Here's a small tip I thought will be useful for us.
Are you paying a premium every year and wondering how much you should expect after x years?
I have a javascript code snippet for you to play around with...
--js code starts--
var calculateCompoundInterest = function(principal, rate, timeInYears) {
return principal * (Math.pow((1+rate/100),timeInYears))
}
var calculateRecurringCompoundInterest = function(principal, rate, timeInYears) {
var finalAmount=0.0;
for(var i=0; i finalAmount+=calculateCompoundInterest(principal,rate,i+1)
}
return finalAmount
}
//fixed one time premium at 5% rate of interest for 11 years
console.log(calculateCompoundInterest(100000,5,11));
//recurring premium at 5% rate of interest for 11 years
console.log(calculateRecurringCompoundInterest(100000,5,11));
--js code ends--
Are you paying a premium every year and wondering how much you should expect after x years?
I have a javascript code snippet for you to play around with...
--js code starts--
var calculateCompoundInterest = function(principal, rate, timeInYears) {
return principal * (Math.pow((1+rate/100),timeInYears))
}
var calculateRecurringCompoundInterest = function(principal, rate, timeInYears) {
var finalAmount=0.0;
for(var i=0; i
}
return finalAmount
}
//fixed one time premium at 5% rate of interest for 11 years
console.log(calculateCompoundInterest(100000,5,11));
//recurring premium at 5% rate of interest for 11 years
console.log(calculateRecurringCompoundInterest(100000,5,11));
--js code ends--
No comments:
Post a Comment