Basic JS exercise 108/110

Hey everyone. My code is below and it works perfectly for the below mentioned exercise. However, the system is not accepting that. Can someone please help me to figure out what’s not working?

Thanks for reading

My code so far

//Only change code below this line
function countdown(n){
if (n > 10 || n<0) {
  return [];
} else {
  const countArray = countdown(n - 1);
  return countArray;
console.log(countdown(10)); // [5, 4, 3, 2, 1]

My browser information:

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

Challenge: Use Recursion to Create a Countdown

Link to the challenge:

Hi and welcome to the forum :slight_smile: You’re on a good track with the challenge. The only problem is that the array that you return isn’t supposed to include 0. (Side note: I don’t think you need to include the n > 10 condition, since the argument can be greater than 10 and your function is still supposed to return the countdown array)

Hope this helps! :smiley:

1 Like