Calculate the value of (m)1/n in JavaScript

JavascriptSAP Web DynproFront End Technology

Problem

We are required to write a JavaScript function that takes in two numbers m and n. Our function should calculate and return the value of the following expression −

(m)1/n

Example

Following is the code −

 Live Demo

const m = 16;
const n = 4;
const findNthRoot = (m, n) => {
   const power = 1 / n;
   const res = Math.pow(m, power);  
   return res;
};
console.log(findNthRoot(m, n));

Output

Following is the console output −

2
raja
Published on 17-Apr-2021 11:50:31
Advertisements