JSFiddle - React, Tailwind, and code Playground

HTML

<input id="pmt" type="button" value="Calculate" />
<input id="result" name="result" placeholeder="result">

JavaScript

//Excel function
//=(PMT(6.5%/12,60,(-B4),(0.2*B4),1))*12/52
//Result = 57.62

//PMT
function pmt(rate_per_period, number_of_payments, present_value, future_value, type){
    if(rate_per_period != 0.0){
        // Interest rate exists
        var q = Math.pow(1 + rate_per_period, number_of_payments);
        return -(rate_per_period * (future_value + (q * present_value))) / ((-1 + q) * (1 + rate_per_period * (type)));

    } else if(number_of_payments != 0.0){
        // No interest rate, but number of payments exists
        return -(future_value + present_value) / number_of_payments;
    }

    return 0;
}

//Set vars
var interest    = 0.065,     // Annual interest
    present     = 15000,    // Present value of loan
    future      = 0.2 * present,    // Future value of loan
    beginning   = 1;        // Calculated at start of each period

document.getElementById("pmt").onclick = function () {
var payment = -pmt(interest / 12,   // Annual interest into months
                   60,      // Total months for life of loan
                   present,
                   future,
                   beginning);

document.getElementById("result").value = (payment*12/52).toFixed(2); //calculate weekly payment

}