JavaScript Find Nth Root of Number

avatar
Published: Feb 03, 2023

The Nth Root of a number is a number that is multiplied by itself n times to get the initial value. Have a look at the Wiki page for more information.

Use Math.pow() to calculate x to the power of 1 / n which is equal to the nth root of x.

const nthRoot = (x, n) => Math.pow(x, 1 / n);

let result = nthRoot(81, 4);

console.log(result) // 3