Update use-recursion-to-create-a-countdown.english.md (#38366)

This commit is contained in:
Shivam saini
2020-03-13 20:35:59 +05:30
committed by GitHub
parent 694e52f742
commit 4ef78f7f7d

View File

@ -27,7 +27,7 @@ function countup(n) {
console.log(countup(5)); // [ 1, 2, 3, 4, 5 ]
```
At first, this seems counterintuitive since the value of `n` <em>decreases</em>, but the values in the final array are <em>increasing</em>. This happens because the push happens last, after the recursive call has returned. At the point where `n` is pushed into the array, `count(n - 1)` has already been evaluated and returned `[1, 2, ..., n - 1]`.
At first, this seems counterintuitive since the value of `n` <em>decreases</em>, but the values in the final array are <em>increasing</em>. This happens because the push happens last, after the recursive call has returned. At the point where `n` is pushed into the array, `countup(n - 1)` has already been evaluated and returned `[1, 2, ..., n - 1]`.
</section>