import Mortgage from './mortgage2'; document.getElementById('calcBtn').addEventListener('click', () => { let principal = document.getElementById("principal").value; let years = document.getElementById("years").value; let rate = document.getElementById("rate").value; let mortgage = new Mortgage(principal, years, rate); document.getElementById("monthlyPayment").innerHTML = mortgage.monthlyPayment.toFixed(2); document.getElementById("monthlyRate").innerHTML = (rate / 12).toFixed(2); let html = ""; mortgage.amortization.forEach((year, index) => html += ` ${index + 1} ${Math.round(year.principalY)}
${Math.round(year.interestY)} ${Math.round(year.balance)} `); document.getElementById("amortization").innerHTML = html; });