showing results for - "basic javascript 3a use recursion to create a countdown"
Emanuele
20 Jul 2017
1function countdown(n){
2  if (n < 1) {
3    return [];
4  } else {
5    const arr = countdown(n - 1);
6    arr.unshift(n);
7    return arr;
8  }
9}
10console.log(countdown(5)); // [5, 4, 3, 2, 1]