Current Mortgage
Refinanced Mortgage
${comparisonResult}
`; }function calculateMonthlyPayment(loanAmount, interestRate, loanTerm) { const monthlyInterestRate = interestRate / 12; const totalPayments = loanTerm * 12; const monthlyPayment = (loanAmount * monthlyInterestRate) / (1 - Math.pow(1 + monthlyInterestRate, -totalPayments)); return monthlyPayment; }