Im looking for a solution to find the loan repayment period in months. To make it clear im trying to implement NPER functionality in Javascript . Spend a day with this , its becoming hopeless id like some help . I tried with Finance.js Library , but they donot have anything for NPER, Then tried to implement NPER logic :
var months = 12;
var rate = 9;
var loanAmount = 150000;
var monthlyPayment = -7000
var j = loanAmount / monthlyPayment;
var k = rate / months;
var x = 1 - (j * k);
var y = 1 + k;
var NPER = (Math.log(x)) / (Math.log(y))
console.log("NPER", NPER);