Basic JavaScript - Use Recursion to Create a Countdown

Tell us what’s happening:
I have no idea why this is not working. The tests it doesnt pass are countDown(10), countDown(5), and global variables should not be used to cache the array.

Your code so far

// Only change code below this line
function countdown(n){
  return n<1 ? [] : [n, countDown(n-1)];
// Only change code above this line

Your browser information:

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

Challenge: Basic JavaScript - Use Recursion to Create a Countdown

Link to the challenge:

I think you want that “D” to be lowercase :slightly_smiling_face:

By definition, the countdown function must always return an array of numbers. What does the above return?

I don’t know. I thought it was an array.

Yes, it is an array, but what type of values are inside of the array. n is definitely a number, but what is countdown(n-1).

Remember, the countdown function returns an array of numbers.

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