Skip to content Skip to sidebar Skip to footer

How To Add A Recurring Interest Rate Onto A Recurring And Growing Amount

I am trying to add the given percentage onto a number repeatedly over a few months that already has the percentage added on from the previous month. I.e, The user defines 25% (this

Solution 1:

You could also try an approach like this:

var interestRate = .25;

var startCash = 10000;

var total=startCash;

for(var monthCount=1; monthCount<13;monthCount++){

    //this line takes the previous value of total and gets the percentage of interest//it is then re-assigned back to the same variable
    total += total*interestRate; 

    console.log('month :', monthCount);
    console.log('total :', total);
 }

Solution 2:

The total from compound interest calculated for the next month should be

addInt = total*interestRate/100 + total;

just like the fifth line of your code.

Solution 3:

You might do as follows;

var interest = 0.25,   // monthly interest
      curVal = 10000,  // current value
    duration = 12,
         sum = Array(duration).fill(interest)
                              .map((c,i) => curVal*Math.pow(1+c,i));
console.log(sum);

Every start of month we are calculating the compound interest and applying it to the face value which is 10,000.

Post a Comment for "How To Add A Recurring Interest Rate Onto A Recurring And Growing Amount"