Write a function called "computeCompoundInterest".
Given a principal, an interest rate, a compounding frequency, and a time (in years), "computeCompoundInterest" returns the amount of compound interest generated.
var output = computeCompoundInterest(1500, .043, 4, 6);
console.log(output); // --> 438.8368221341061
Reference: https://en.wikipedia.org/wiki/Compound_interest#Calculation_of_compound_interest This shows the formula used to calculate the total compound interest generated.
Problem is i am trying to use this formula and can't get it right
function computeCompoundInterest(p, i, compoundingFrequency, timeInYears) {
p = p * (1 + (i/4)))^(compoundingFrequency*timeInYears)
}
I tried to step through each calculation and it looks like once I get to:
p = 1500 * (1 + 0.043/4)^ 4 x 6 //compoundingFrequency = 4 and timeInYears = 6
I am doing something wrong. This website seems to get a decimal number when you (1 + (i/4)))^(compoundingFrequency*timeInYears)