Функция PMT в Javascript

Я хочу использовать функцию Excel PMT в Javascript. Параметр будет

Pmt (процентная ставка, количество_платежей, ТС, БС, Тип)

interest_rate : the interest rate for the loan.
number_payments : the number of payments for the loan.
PV : the present value or principal of the loan.
FV : It is the future value or the loan amount outstanding after all payments have been made. 

Type is : It indicates when the payments are due. Type can be one of the following values:
 0, 1

Вы можете обратиться: http://www.techonthenet.com/excel/formulas/pmt.php

это код, который я использую, я застрял в последнем параметре. Какой "тип" - 0 или 1. Как это влияет на вычисления, пожалуйста.

function PMT (ir, np, pv, fv ) {
 /*
 ir - interest rate per month
 np - number of periods (months)
 pv - present value
 fv - future value (residual value)
 */
 pmt = ( ir * ( pv * Math.pow ( (ir+1), np ) + fv ) ) / ( ( ir + 1 ) * ( Math.pow ( (ir+1), np) -1 ) );
 return pmt;
}

Мне нужен простой Javascript, а не jQuery, пожалуйста.

10
задан Brian Tompsett - 汤莱恩 26 August 2019 в 21:57
поделиться