JSFiddle - React, Tailwind, and code Playground
by wisegorilla
JavaScript
const apr = (4.99 / 100);
function getMonthlyPayment(balance, apr, months) {
// Get our monthly payment calculated by amortization (daily compounded).
// http://www.vertex42.com/ExcelArticles/amortization-calculation.html
// http://en.wikipedia.org/wiki/Amortization_calculator
// We first need to figure out our monthly compounded payment rate.
var r = Math.pow(1 + (apr / 360), (360 / 12)) - 1;
// Now we can use our monthly rate to figure out our monthly payment.
return balance * ((r * Math.pow(1 + r, months)) / (Math.pow(1 + r, months) - 1));
}
console.log(getMonthlyPayment(200000, apr, 60))