ปัญหา
เราจำเป็นต้องเขียนฟังก์ชัน JavaScript ที่ใช้ตัวเลขสองตัว m และ n ฟังก์ชันของเราควรคำนวณและส่งกลับค่าของนิพจน์ต่อไปนี้ -
(m)1/n
ตัวอย่าง
ต่อไปนี้เป็นรหัส -
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)); ผลลัพธ์
ต่อไปนี้เป็นเอาต์พุตคอนโซล -
2