Chuong Dao Chuong Dao - 8 months ago 39
Javascript Question

How to input the equation with power of number in Javascript?

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


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.)