Money Consolidation Loan Calculator

Money Consolidation Loan Calculator

Calculation Steps

function calculateLoan() { const totalDebt = parseFloat(document.getElementById(“totalDebt”).value); const interestRate = parseFloat(document.getElementById(“interestRate”).value) / 100 / 12; const loanTerm = parseInt(document.getElementById(“loanTerm”).value) * 12; if (isNaN(totalDebt) || isNaN(interestRate) || isNaN(loanTerm) || totalDebt <= 0 || interestRate <= 0 || loanTerm <= 0) { alert("Please enter valid positive values for all fields."); return; } const monthlyPayment = (totalDebt * interestRate) / (1 – Math.pow(1 + interestRate, -loanTerm)); const totalPaid = monthlyPayment * loanTerm; document.getElementById("monthlyPayment").value = monthlyPayment.toFixed(2); document.getElementById("totalPaid").value = totalPaid.toFixed(2); const steps = ` Inputs:
Total Debt: $${totalDebt.toFixed(2)}
Interest Rate: ${(interestRate * 100 * 12).toFixed(2)}%
Loan Term: ${loanTerm / 12} years

Formulas:
Monthly Payment = (Total Debt × Monthly Interest Rate) ÷ (1 – (1 + Monthly Interest Rate)^(-Loan Term))
Total Paid = Monthly Payment × Loan Term

Results:
Monthly Payment: $${monthlyPayment.toFixed(2)}
Total Paid Over the Term: $${totalPaid.toFixed(2)}
`; document.getElementById(“steps”).innerHTML = steps; document.getElementById(“calculationSteps”).style.display = “block”; } function resetForm() { document.getElementById(“consolidation-loan-calculator-form”).reset(); document.getElementById(“monthlyPayment”).value = ”; document.getElementById(“totalPaid”).value = ”; document.getElementById(“calculationSteps”).style.display = “none”; }

Leave a Reply

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