Amortization Table
| Month |
Payment |
Principal |
Interest |
Balance |
function calculateAmortization() {
const loanAmount = parseFloat(document.getElementById(‘loanAmount’).value);
const interestRate = parseFloat(document.getElementById(‘interestRate’).value) / 100 / 12;
const loanTerm = parseInt(document.getElementById(‘loanTerm’).value) * 12;
const monthlyPayment = (loanAmount * interestRate) / (1 – Math.pow(1 + interestRate, -loanTerm));
let balance = loanAmount;
let amortizationTable = ”;
for (let month = 1; month <= loanTerm; month++) {
const interestPayment = balance * interestRate;
const principalPayment = monthlyPayment – interestPayment;
balance -= principalPayment;
amortizationTable += `
| ${month} |
${monthlyPayment.toFixed(2)} |
${principalPayment.toFixed(2)} |
${interestPayment.toFixed(2)} |
${balance.toFixed(2)} |
`;
}
document.getElementById(‘amortizationTable’).getElementsByTagName(‘tbody’)[0].innerHTML = amortizationTable;
}