Loan repayment calculator

This script calculates loan repayments.

Programming Issues

The loanRepay() function is called when the push button is clicked, generating the onclick event, and calculates both the monthly repayment and the total repayments based on the principle, APR and loan length that the user enters. The script uses the same Math.round and Math.pow functions described in our basic mathematical calculations example.

A simple monthly rate is calculated by taking the twelfth root of the APR. This simple monthly rate is then used to calculate the monthly repayment using a standard formula. The total repayment is just this monthly repayment multiplied by the number of months the loan will be outstanding.

Demonstration

Enter the principal loan amount:
Enter the annual percentage rate (APR): %
Enter the length of the loan: months
The monthly repayment amount is:
The total repayment amount is:

Source and Downloads