PMT function in Javascript

0 votes

I want to use the 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

this is the code I use, I am stuck on the last parameter. Which is "type is" 0 or 1. How does it affect 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.

Dec 12, 2022 in Others by Kithuzzz
• 38,000 points
2,068 views

1 answer to this question.

0 votes
Try the following settings to better understand the effect of the Type parameter: Present Value = 100, Annual Interest = 12%, Number of Months = 1.

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

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

Because it is assumed that the payment would be made at the end of the month when Type=0, the interest is calculated for 1 month. Because the payment is made at the beginning of the month, Type=1 computes interest for 0 months.
answered Dec 13, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

What is a name function in JavaScript & how to define it?

A named function declares a name as ...READ MORE

answered Mar 7, 2019 in Others by Frankie
• 9,830 points
4,700 views
0 votes
1 answer

How can you create an object in JavaScript?

JavaScript supports Object concept very well. You can create ...READ MORE

answered Mar 7, 2019 in Others by Frankie
• 9,830 points
597 views
0 votes
1 answer

How can you create an Array in JavaScript?

You can define arrays using the array literal as ...READ MORE

answered Mar 7, 2019 in Others by Frankie
• 9,830 points
650 views
0 votes
0 answers

Can we write AES enryption in Javascript and Decryption in Java using a static SALT and IV

I'm working on AES encryption I want to ...READ MORE

Jun 4, 2019 in Others by Eighteen
• 120 points
1,903 views
0 votes
1 answer

Calculate slope and intercept value for logarithmic trendline as excel

You missed Math.log() for ln() in Excel. ...READ MORE

answered Nov 8, 2022 in Others by narikkadan
• 63,600 points
1,242 views
0 votes
1 answer

Calculate Birthdate from an age using y,m,d in Excel

Hello, yes u can find your birthdate using ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
4,135 views
0 votes
1 answer

Calculate Birthdate from an age using y,m,d in Excel

Hi To Calculate the date, we can ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
2,014 views
0 votes
0 answers

Convert Rows to Columns with values in Excel using custom format

1 I having a Excel sheet with 1 ...READ MORE

Feb 17, 2022 in Others by Edureka
• 13,690 points
994 views
0 votes
1 answer

Excel-VBA - How to identify Target range (more than 1 cell) is deleted in a Worksheet_Change function?

You misunderstand the purpose of the function ...READ MORE

answered Sep 23, 2022 in Others by narikkadan
• 63,600 points
3,755 views
0 votes
1 answer

IF function in combination with an Round function Excel

I'm not sure if it is a ...READ MORE

answered Sep 25, 2022 in Others by narikkadan
• 63,600 points
3,617 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP