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

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

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 1,348 views

## 1 answer to this question.

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
• 63,420 points

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

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

## How can you create an object in JavaScript?

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

## How can you create an Array in JavaScript?

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

## 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

## Calculate slope and intercept value for logarithmic trendline as excel

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

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

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

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

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

## Convert Rows to Columns with values in Excel using custom format

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