Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
181
rated 0 times [  183] [ 2]  / answers: 1 / hits: 36124  / 14 Years ago, mon, march 14, 2011, 12:00:00

I want to use Excel PMT function in Javascript.
The parameter would be



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


You can refer :
http://www.techonthenet.com/excel/formulas/pmt.php



this is the code I use, I am stuck in last parameter. Which is type is 0 or 1. How it effect the calculations please.



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;
}


I need it in plain Javascript and not in jQuery please.


More From » excel

 Answers
33

The easiest way to understand the impact of the Type parameter is to try the following values: Annual Interest = 12%, # of Months = 1, Present Value = 100



When Type=0 (the default), the PMT() function will yield 101



When Type=1, the PMT() function will yield 100



With Type=0, the interest is computed for 1 month because the payment is assumed to be at the end of the month. For Type=1, the interest is computed for 0 months because the payment is at the beginning of the month.


[#93300] Friday, March 11, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shelbiec

Total Points: 101
Total Questions: 106
Total Answers: 106

Location: Ivory Coast
Member since Fri, Oct 8, 2021
3 Years ago
;