编辑代码

// TODO: have some bug when like 1 / 3
// Use Math.pow() to calculate x
// to the power of 1/n which is equal to the nth root of x.
const nthRoot = (num, n) => (Math.pow(num, 1 / n));
// Math.pow() 函数返回基数(base)的指数(exponent)次幂,即 base^exponent

console.log(Math.pow(7, 3)); 
console.log(nthRoot(27, 3));
console.log(nthRoot(64, 3));
console.log(nthRoot(110, 10));