Loan Calculator Malaysia Public Bank

Loan Calculator – Public Bank Malaysia

function calculateLoan() { const loanAmount = parseFloat(document.getElementById(‘loanAmount’).value); const interestRate = parseFloat(document.getElementById(‘interestRate’).value) / 100; const loanTerm = parseInt(document.getElementById(‘loanTerm’).value); if (!loanAmount || !interestRate || !loanTerm) { alert(‘Please fill in all fields’); return; } const monthlyInterestRate = interestRate / 12; const numberOfPayments = loanTerm * 12; const monthlyRepayment = (loanAmount * monthlyInterestRate) / (1 – Math.pow(1 + monthlyInterestRate, -numberOfPayments)); const totalRepayment = monthlyRepayment * numberOfPayments; document.getElementById(‘monthlyRepayment’).value = monthlyRepayment.toFixed(2); document.getElementById(‘totalRepayment’).value = totalRepayment.toFixed(2); }

Leave a Reply

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