user1525 - 7 months ago 41

Javascript Question

I have the following formula in Excel.

F14 = 100000

F15 = 10

F16 = 10

`=(((1+F16)^(1/12)-1)*F14)/(1-((1+((1+F16)^(1/12)-1))^(-F15*12)))`

This results in 1,297.75 which is correct. Simply trying to use the same formula in js gives a result of 8800, obviously wrong.

As I understand it, ^ should be replaced by Math.pow(A,B), correct? Even so, I'm having real trouble making this out correctly.

Could anybody help me out?

EDIT: Everything is good. The formula I posted was slightly different than the one in excel (don't know how i made that happen). Everything is good and makes sense now. Thanks everybody

Answer

In my Excel, I get the value of `22118,85503`

and so does this

```
var F14 = 100000,
F15 = 10,
F16 = 10;
console.log(((Math.pow(1 + F16, 1 / 12) - 1) * F14) / (1 - (Math.pow(1 + (Math.pow(1 + F16, 1 / 12) - 1), -F15 * 12))));
```