In the lesson https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-countdown I’ve implemented the solution but fail
Tell us what’s happening:
I get this with all clarity even I wrote the stack of recursion. But the test is not passing my code when pass 10 and 5 as arguments. The format is the same that is requested in the description.
Your code so far
// Only change code below this line
function countdown(n){
if(n<0) return [];
arrayReturned = countdown(n-1);
arrayReturned.unshift(n);
return arrayReturned;
}
// Only change code above this line
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36
.
Challenge: Use Recursion to Create a Countdown
Link to the challenge: