My code isn't passing all test

Tell us what’s happening:
My code isn’t passing all test. I checked and everything looks fine I don’t know why it isn’t passing.

  **Your code so far**

// Only change code below this line
let arr = [];
function countdown(n){
if(n >= 1 ) {
  arr.push(n);
 return  countdown(n - 1);
}else if(n < 1) {
  return [];
}
  
}
// Only change code above this line
countdown(5)
console.log(arr);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.87 Safari/537.36

Challenge: Use Recursion to Create a Countdown

Link to the challenge:

Hey.
Here’s what the assignment says:

The function should use recursion to return an array containing the integers n through 1 based on the n parameter

The function should build and return the array. All your function returns is an empty array.

Hope this helps.

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.