Skip to content

Instantly share code, notes, and snippets.

@gpbaculio
Last active April 30, 2017 17:26
Show Gist options
  • Save gpbaculio/5c275c60d7b4fafc8b65e28d204620df to your computer and use it in GitHub Desktop.
Save gpbaculio/5c275c60d7b4fafc8b65e28d204620df to your computer and use it in GitHub Desktop.
function power(base, exponent) {
if (exponent == 0) {
return 1;
}
else {
return base * power(base, exponent - 1);
}
}
console.log(power(2, 3));
// → 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment