Mortgage Payment Calculator Project
Make a web app that has input fields for a mortgage loan amount, interest rate, and number of payments, and uses those values to calculate the monthly loan payment.
Use the following formula:
P * r (1 + r)^n P = Principal Loan amount ($)
------------------- r = Monthly Interest Rate (decimal)
(1 + r)^n - 1 n = Number of Payments (months)
Demo
Requirements
- Have a "Calculate" button, which will show the answer on the page when clicked.
- Have it display the answer with no more than 2 decimals.
- Be sure to convert the values to floats after you extract them from page input fields.
Hints
Code for displaying a number to 2 decimals
Specify precision within the parenthesis of the toFixed() function
var answer = ...
console.log(answer.toFixed(2))
Code for extracting values and converting them to floats
var value = parseFloat( document.getElementById("myInput").value );