【发布时间】:2011-07-14 17:23:05
【问题描述】:
我想在 Javascript 中使用 Excel PMT 函数。 参数将是
Pmt(interest_rate, number_payments, PV, FV, Type)
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
这是我使用的代码,我被困在最后一个参数中。哪个是“type is” 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。
【问题讨论】:
标签: javascript excel excel-formula javascript-framework