Nab Personal Car Loan Calculator

NAB Personal Car Loan Calculator

function calculateNabCarLoan() { const loanAmount = parseFloat(document.getElementById(‘loanAmount’).value); const loanTerm = parseInt(document.getElementById(‘loanTerm’).value); const interestRate = parseFloat(document.getElementById(‘interestRate’).value); if (isNaN(loanAmount) || isNaN(loanTerm) || isNaN(interestRate) || loanAmount <= 0 || loanTerm <= 0 || interestRate <= 0) { alert('Please enter valid values for all fields.'); return; } const monthlyInterestRate = interestRate / 100 / 12; const numberOfPayments = loanTerm * 12; const monthlyPayment = loanAmount * monthlyInterestRate / (1 – Math.pow(1 + monthlyInterestRate, -numberOfPayments)); if (isFinite(monthlyPayment)) { document.getElementById('monthlyPayment').value = monthlyPayment.toFixed(2); } else { alert('Error in calculating monthly payment.'); } }

Leave a Reply

Your email address will not be published. Required fields are marked *