Created
April 3, 2017 21:20
-
-
Save radovansurlak/a257778f7e131ff1325031144f73dd77 to your computer and use it in GitHub Desktop.
JS Recursive Function + Ternary Operator - Power
This file contains hidden or 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
function power (num, pow) { | |
return (pow === 0) ? 1 : num * power(num, pow-1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a prototype extension, but I have read that extending prototypes might break things up.