mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-25 04:56:23 +00:00
17 lines
276 B
Markdown
17 lines
276 B
Markdown
---
|
|
date: 2020-07-02
|
|
id: f77e6e36-1674-46b6-a8c9-d5a77d40f19e
|
|
title: Recursion in JavaScript
|
|
---
|
|
|
|
``` javascript
|
|
function power(base, exponent) {
|
|
if (exponent == 0) {
|
|
return 1;
|
|
} else {
|
|
return base * power(base, exponent - 1);
|
|
}
|
|
}
|
|
|
|
console.log(power(2, 3));
|
|
```
|