Charles Sipe's Portfolio
Loan Payment Calculator Using JavaScript
Loan Amount: $
Interest Rate:
Months:
Code by Adam Khoury
HTML code:
Loan Amount: $
Interest Rate:
Months:
JavaScript code:
function computeLoan(){ var amount = document.getElementById('amount').value; var interest_rate = document.getElementById('interest_rate').value; var months = document.getElementById('months').value; var interest = (amount * (interest_rate * .01)) / months; var payment = ((amount / months) + interest).toFixed(2); payment = payment.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); document.getElementById('payment').innerHTML = "Monthly Payment = $"+payment; }
If you have a recommendation, please contact me.