1

Can anyone help me to convert this VB script to equivalent Javascript please.

PMT = ((PV - FV) * rate/ (1 - (1 + rate) ^ -(nper)))
5
  • This is already valid javascript, you should keep this in the existing thread Commented Mar 18, 2011 at 15:38
  • @Martin Jespersen JavaScript doesn't have an exponentiation operator ... Commented Mar 18, 2011 at 15:39
  • Sorry Martin, ^ is not a power function in JavaScript. Commented Mar 18, 2011 at 15:39
  • 1
    @Everyone: sorry, my bad shakes his tired friday head Commented Mar 18, 2011 at 15:41
  • @Pointy @Diodeus maybe he wanted a bitwise XOR ! Commented Mar 18, 2011 at 16:06

1 Answer 1

6

Probably

var PMT = ((PV - FV) * rate / (1 - Math.pow(1 + rate, -nper)));

JavaScript numbers are always (at heart) floating-point values, so when you're dealing with money things can get somewhat weird.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Pointy, I added this values : var pmt = ((100000 - 0) * (7.5/12) / (1 - Math.pow(1 + (7.5/12), -48))); both result does not match.. any ideas please..
My objective is to do the following math : stackoverflow.com/questions/5353511/pmt-in-javascript
The result doesn't match what?? Also, if the interest rate is 7.5%, you probably should be using 0.075 and not 7.5.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.