Created
August 24, 2022 18:05
-
-
Save thawkin3/6930f74c8a57aad4cd50316f21361080 to your computer and use it in GitHub Desktop.
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
export const power = (x, y) => { | |
if (y < 0) { | |
throw new Error( | |
'exponent must be greater than or equal to 0 (for the purposes of this example)' | |
); | |
} | |
if (y === 0) { | |
return 1; | |
} | |
return x * power(x, y - 1); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment