wiki/content/20200702204437-recursion.md

259 B

id title
f77e6e36-1674-46b6-a8c9-d5a77d40f19e Recursion in JavaScript
function power(base, exponent) {
  if (exponent == 0) {
    return 1;
  } else {
    return base * power(base, exponent - 1);
  }
}

console.log(power(2, 3));