Countdown(-1) should return an empty array. countdown(10) should return [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] countdown(5) should return [5, 4, 3, 2, 1]

Tell us what’s happening:

Your code so far


// Only change code below this line
function countdown(n) {
if (n < 1) {
  return [];
} else {
  const countArray = countdown(n - 1);
  countArray.push(n);
  return countArray;
}
}
console.log(countup(5)); 
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36.

Challenge: Use Recursion to Create a Countdown

Link to the challenge:

Hello,

Your function name is countdown yet you’re logging countup in the console. Nothing would show up in the console. After logging the right function you would know if your code works just as intended. Hope this helps

Happy Coding.