I am completely lost

Tell us what’s happening: I do not understand what I am supposed to do here. I am completely lost

Your code so far


//Only change code below this line
function countdown(myArray, n){
return;
}

Your 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:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-countdown

I told you that the array passed to countdown would be an empty array, would that help? What part of the instructions are you not understanding?

1 Like

To be honest. I did not understand the exercises on recursive. I still do not know what they are and used for

The best way I can explain it is like a For Loop “on steroids”…

function countdown(myArray, n){
...do stuff...
if(n === 100) return something
countdown(myArray, n+1)
}

That will run when called & if n isn’t 100, it will run again with n+1. And then keep running until n = 100. It’s a simple example, but basically it just keeps running its self over and over until you want it to ‘return’ something

1 Like

Thank you so much I got a little bit of insight there. So what it does is the function runs until the if condition is met after which it returns something and stops.