Auto Loan Calculator 75 Months

Auto Loan Calculator – 75 Months

Loan Details

function calculateAutoLoan() { const loanAmount = parseFloat(document.getElementById(‘loanAmount’).value); const interestRate = parseFloat(document.getElementById(‘interestRate’).value) / 100; const loanTerm = parseInt(document.getElementById(‘loanTerm’).value); if (isNaN(loanAmount) || isNaN(interestRate) || isNaN(loanTerm)) { alert(‘Please enter valid values for all fields.’); return; } const monthlyRate = interestRate / 12; const monthlyPayment = (loanAmount * monthlyRate) / (1 – Math.pow(1 + monthlyRate, -loanTerm)); const totalPayment = monthlyPayment * loanTerm; const totalInterest = totalPayment – loanAmount; document.getElementById(‘monthlyPayment’).value = monthlyPayment.toFixed(2); document.getElementById(‘totalInterest’).innerText = `Total Interest: $${totalInterest.toFixed(2)}`; document.getElementById(‘totalPayment’).innerText = `Total Payment: $${totalPayment.toFixed(2)}`; document.getElementById(‘loanDetails’).style.display = ‘block’; }

Leave a Reply

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