Tell us what’s happening:
The code produces the required answer but for some reason it fails the test. Does anyone know what the problem is
Your code so far
js
//Only change code below this line
function countdown(myArray, n){
if(n<=0){
return;
} else if (n==1) {
return [1] ;
} else {
myArray = countdown(myArray,n-1);
myArray.unshift(n);
return myArray;
}
}
var myArray;
console.log(countdown(myArray,5));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; 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:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-countdown