Question: I am trying to calculate the monthly payment of a loan and it always comes out wrong.

The formula is as follows where i is interest

```
((1 + i)^months /
(1 + i)^months - 1)
* principal * i

```

Assuming that annual interest rate and principal is an invisible floating point, can you tell me what's wrong with my formula?

```
double calculatePaymentAmount(int annualInterestRate, 
     int loanSize,                          
     int numberOfPayments;
{
double monthlyInterest = annualInterestRate / 1200.0;
return 
    (
        pow(1 + monthlyInterest, numberOfPayments) /
        (pow(1 + monthlyInterest, numberOfPayments) - 1)
    )
    * (loanSize / 100)
    * monthlyInterest;
}

```

For example: an interest rate of 1.25 and a loan size of 250 for 12 months gives 22.27 instead of 20.97.

Thank you in advance.

Edit 1: Changed monthly interest to annualInterestRate / 1200

Answer: 
If you didn't, `john.property` would be undefined.
The `this` keyword is used to refer to the owner of the function executed:

<http://www.quirksmode.org/js/this.html>

As said, you need it to define the `john.property`, because the `property` variable passed to the function will expire once the function is executed.