Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Implementing Math function and return m^n in JavaScript
We are required to write a JavaScript function that takes in two numbers say m and n. Then function should calculate and return m^n.
For example − For m = 4, n = 3, then
power(4, 3) = 4^3 = 4 * 4 * 4 = 64 power(6, 3) = 216
The code for this will be the following using the power() function in JavaScript −
Example
const power = (m, n) => {
if(n Output
And the output in the console will be −
64
216
Advertisements
