Car Loan Calculator Navy Federal Credit Union

Navy Federal Credit Union Car Loan Calculator

Loan Payment Results

function calculateLoan() { let loanAmount = parseFloat(document.getElementById(‘loanAmount’).value); let interestRate = parseFloat(document.getElementById(‘interestRate’).value) / 100 / 12; let loanTerm = parseFloat(document.getElementById(‘loanTerm’).value) * 12; if (isNaN(loanAmount) || isNaN(interestRate) || isNaN(loanTerm)) { alert(“Please fill in all fields correctly.”); return; } let monthlyPayment = (loanAmount * interestRate) / (1 – Math.pow(1 + interestRate, -loanTerm)); let totalInterest = (monthlyPayment * loanTerm) – loanAmount; let totalLoanCost = loanAmount + totalInterest; document.getElementById(‘monthlyPayment’).innerText = `Monthly Payment: $${monthlyPayment.toFixed(2)}`; document.getElementById(‘totalInterest’).innerText = `Total Interest: $${totalInterest.toFixed(2)}`; document.getElementById(‘totalLoanCost’).innerText = `Total Loan Cost: $${totalLoanCost.toFixed(2)}`; document.getElementById(‘loanResults’).style.display = ‘block’; }

Leave a Reply

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