Created
August 14, 2018 00:21
-
-
Save Samuelachema/0eac832224ed7acf6d3c7ee0a72359d4 to your computer and use it in GitHub Desktop.
Write a function named power that accepts two arguments, a and b and calculates a raised to the power b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Write a function named power that accepts two arguments, a and b and calculates a raised to the power b. | |
Example | |
power(2, 3) => 8 | |
Note: Don't use | |
2 ** 3 | |
and don't use | |
Math.pow(2, 3) | |
*/ | |
function power(a,b){ | |
return b--?a*power(a,b):1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
b--?a*power(a,b):1;, someone explain this line of code..