How to do to the nth power in Javascript

Viewed 79

I have a function that I need to handle in Javascript:

equipment * ((rate/12) / ((1-(1+(rate/12))^-term)))

How do I convert it (^) into Javascript?

This is what it looks like so far:

const calculation = equipment * ((rate / 12) / ((1 - (1 + (rate / 12)) - term)));
2 Answers

JavaScript has an operator for it:

console.log(3 ** 5);

Try using this:

let result = Math.pow(3, 5)
//or
let result = 3 ** 5

This is equivalent to 3^5

Related