Basic JavaScript: Use Recursion to Create a Countdown #2

Tell us what’s happening:
'countdown(-1)did not return an empty array.countdown(10) did return [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] countdown(5) did not return [5, 4, 3, 2, 1]`
Your code so far
function countdown(n) {
if (n < 1) {
return ;
} else {
const arr = countdown(n - 1);
arr.unshift(n);
return arr;
}
}
return myArray;
}
console.log(countdown(-1));


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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36 OPR/67.0.3575.130.

Challenge: Use Recursion to Create a Countdown

Link to the challenge:

Your return is outside the countdown function.

function countdown(n) {
  if (n < 1) {
    return [];
  } else {
    const arr = countdown(n - 1);
    arr.unshift(n);
    return arr;
  }
  return myArray;
}

console.log(countdown(-1));