title: PMT function in Javascript
body: <p>I want to use Excel PMT function in Javascript. 
  The parameter would be </p>
  
  <p>Pmt( interest_rate, number_payments, PV, FV, Type )</p>
  
  <pre><code>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
  </code></pre>
  
  <p>You can refer :
  <a href="http://www.techonthenet.com/excel/formulas/pmt.php" rel="noreferrer">http://www.techonthenet.com/excel/formulas/pmt.php</a></p>
  
  <p>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.</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>I need it in plain Javascript and not in jQuery please.</p>