Here's a sample code of a mortgage calculator in JavaScript:
1764 chars45 lines
This code creates a form with input fields for loan amount, interest rate, and loan term. When the user clicks on the "Calculate" button, the calculate()
function is called, which computes the monthly payment using the formula:
M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
where M is the monthly payment, P is the loan amount, i is the monthly interest rate, and n is the total number of months in the loan term.
The monthly payment is then displayed in the "Monthly Payment" field.
gistlibby LogSnag