1 Stop Mortgage Calculator - Calculate your Mortgage payments in Seconds!
Mortgage Calculator Code - Part 3, JavaScript mortgage interest calculations

# Mortgage calculator code

Part 3
Interest calculations

In part 2 of this Mortgage calculator code series, we finished by dividing the JavaScript mortgage formula into 2 parts:

The first formula finds the real interest rate and the second one finds the periodic payment:

IntRate = AnnualIntRate / PPay

Pa = (PrValue * IntRate) / (1 - Math.pow (1 + IntRate, - Period) )

The interest rate is IntRate, AnnualIntRate is the annual interest rate, PPay is the number of payments per year, Pa represents the payment, PrValue is the present value of the loan, tand Period is the number of years the money is borrowed.

The interest calculations have to take care of 2 things: the compounding period (monthly in the US) and the payment period.

Therefore, the Interest calculations are not exacly as shown above. The real interest rate has to be adjusted to our payment cycle, which implies that we also have to adjust the period to our payment cycle... like this:

IntRate = AnnualIntRate / PPay

Pa = (PrValue * IntRate) / (1 - Math.pow (1 + IntRate, - (Period * PPay) )

If this formula was for monthly mortgage payments, PPay would be 12.

Next topic: Canadian mortgage calculator code

To hard to program? Just click on this link to get 4 ready-to-use JavaScript mortgage calculators for your website or for offline use on your computer!