Chuong Dao - 1 year ago 66

Javascript Question

I am currently learning Javascript and here is my struggle with my homework, hope you guys can help me with this one:

`futureInvestment = investmentAmount * (1 + monthlyInterestRate)^numberOfYears*12`

How to implement this equation? Thanks

Answer Source

Use the `Math.pow()`

function.

To calculate `x^y`

say `Math.pow(x, y)`

. For example:

```
Math.pow(2, 4) // returns 16
Math.pow(13, 3) // returns 2197
```

*(Since you've mentioned that you're working on homework I'll give you a chance to figure out for yourself how to apply Math.pow() to your particular calculation rather than just giving you the final answer immediately.)*