# Javascript Function – Math.pow() – Mortgage Calculator

##### In this video, we create a javascript function that uses Math.pow() to calculate a mortgage payment.

Hello everyone today we’re going to be given a formula to calculate a mortgage and then take that formula and make a javascript function that does the same thing so let’s um uncomment that so you can read it a little easier so given this formula here which is the payment equals principal times interest divided by 1 minus 1 plus the interest rate to the power

Of the mortgage periods so given that formula we’ll make a javascript function so let’s go ahead and comment that out again and we’ll start out by creating a variable to represent the monthly interest rate since we’re going to be figuring the monthly payment so we need to let the monthly interest equal the interest rate that we’re given divided by 100 because

We need a percent so 3.875 in percentage form would be 0.08 or 03 875 so we divide that by 100 to get the interest rate in the form of a percentage and then we divide that by 12 to get the monthly interest rate okay and then we need to have the number of months that this mortgage will be done will be available or will be in force so the months will equal the

Loan years that we’re given times 12. and that’ll be the number of months okay so now we just need to take the formula and put it into the monthly payment variable so monthly payment equals the interest rate i’m sorry the the loan amount times the monthly interest rate and then divide that by one minus we’re going to use the math dot pow function so we