Basic JavaScript: Use Recursion to Create a Countdown question

Tell us what’s happening:
Can somebody tell me what I’ve done wrong?

Your code so far


// Only change code below this line
function countdown(n){
if (n < 1);
return[];
} else {
const countArray = countdown(n - 1)
countArray.push(n)
return countArray;
}
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 9; LM-X420) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Mobile Safari/537.36.

Challenge: Use Recursion to Create a Countdown

Link to the challenge:

Here you have a ; instead of an {

As for the function, it’s currently counting up instead of down. :slight_smile:

Tell us what’s happening:

Your code so far


// Only change code below this line
function countdown(n) {
if (n > 1) {
return[];
} else {
const countArray = countdown(n + 1)
countArray.push(n)
return countArray;
}
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 9; LM-X420) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Mobile Safari/537.36.

Challenge: Use Recursion to Create a Countdown

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

The more information you give us, the more likely we are to be able to help.

Tell us what’s happening:
Can somebody tell what I have done wrong?

Your code so far


// Only change code below this line
function countdown(n) {
if (n > 1) {
return[];
} else {
const countArray = countdown(n + 1)
countArray.push(n)
return countArray;
}
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 9; LM-X420) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Mobile Safari/537.36.

Challenge: Use Recursion to Create a Countdown

Link to the challenge:

Please do not create duplicate topics for the same challenge/project question(s). I will merge this into your previous topic.

Thank you.

Tell us what’s happening:
Can somebody tell what I have done wrong?

Your code so far


// Only change code below this line
function countdown(n) {
if (n > 1) {
return[];
} else {
const countArray = countdown(n + 1)
countArray.push(n)
return countArray;
}
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 9; LM-X420) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Mobile Safari/537.36.

Challenge: Use Recursion to Create a Countdown

Link to the challenge:

You’ve created three threads for the same topic. I have combined them for you.