JSFiddle - React, Tailwind, and code Playground
JavaScript
var MonthlyPaymentAmount = parseFloat(301000);
var APR = 9 / 100; //16.9% APR
var InterestRate = (APR / 12); //monthly interest
var monthly = 3500;
var a = Math.log((monthly/InterestRate)/ ((monthly/InterestRate)-MonthlyPaymentAmount) )/ Math.log(1 + InterestRate );
alert(a);