The Power Function
EasyAcc. 93.7%
+20 XP 8
Manual Exponentiation
You need to calculate the result of base raised to the exponent power manually.
The Assignment
Your function receives parameters base and exponent.
- Initialize
resultto 1. - Use a loop to multiply
resultby thebasefor a total ofexponenttimes. - After the loop, print the
result.
[!NOTE] Any number to the power of 0 is 1.
01EXAMPLE 1
Input
base=2, exponent=3Output
8Explanation: 2 * 2 * 2 = 8
Constraints
- Do not use Math.pow() or the ** operator.
- Use a standard for or while loop.
MathLoops
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
base2
exponent3
Expected Output
8
Click RUN to test your solution