# Did you make a recursive call to countDownRecursive() with count decremented?

I have a problem solving a sentence, the solution that I think makes sense has an error message
Did you make a recursive call to countDownRecursive() with count decremented?

countDownIterative() is a function that accepts a number and counts down to 0 using a loop.

Using what you know of recursion, create a recursive version of countDownIterative() by completing the function countDownRecursive() so that it uses recursion instead to count down.

function countDownIterative(count) {
while(count>0) {
console.log(count);
count–;
}
console.log(‘Blast Off~!’);
}
console.log(‘Iterative Countdown:’);
countDownIterative(3);

function countDownRecursive(count) {

}

console.log(‘Recursive Countdown:’);
countDownRecursive(3);

Function:
function countDownRecursive(count) {
if (count === 0) {
console.log(‘Blast Off~!’);
} else {
console.log(count);
countDownRecursive(count - 1);
}
}

Will someone give some tips on how to approach this task?

Is that function intentionally empty while you pursue the build of your program?

Yes, I have given the content of the task and below is the solution of the function

Can you share a link to the exercise?

Perhaps, you aren’t matching the specifications in the instructions exactly. Looking at the exercise should offer some clues as to the nature of the issue.

Well, seeing as you provided the solution, the best I could do is explain what’s happening.

Recursive functions are functions which call themselves somewhere in their function body. By calling themselves within themselves, they create recursive loops. Like iterative loops, recursive loops need conditions that cause them to stop looping, or else they would loop indefinitely. You may have already learned this if you’re presented with this challenge, but the ending conditions for recursive functions are often called the “base case”.

With that said, let’s break the solution down:

``````function countDownRecursive(count) {
// here we establish the base case i.e. if count has reached 0, then we log and stop looping
if (count === 0) {
console.log(`Blast Off~!')
// next, we establish what happens if the base case has not been reached: we log out the current count and then call this function again with our current count decremented by 1
} else {
console.log(count)
countDownRecursive(count - 1)
}
}
``````
1 Like

Hi! the same is happening to me:

function countDownRecursive(count) {
if (count === 0) {
console.log(‘Blast Off~!’);
} else {
console.log(count);
countDownRecursive(count - 1);
}
}

this is my solution, but it says: Did you make a recursive call to countDownRecursive() with count decremented?
and i cant finish the exam

1 Like

did you find the solution ?

Did you find the solution ?

You are obviously stuck on the lesson, maybe you could post a link to the exercise. Think about it, please.

It’s one of the questions of the exam. It keeps saying “Did you make a recursive call to `countDownRecursive()` with `count` decremented?”

1 Like

We’re at a bit of a disadvantage since in all fairness we should not be helping someone pass an exam. It’s a solo effort intended to corroborate our level of development. Given the exam can be retaken, there is no harm in fumbling so long as we are aware of the question or questions that gave us difficulty. Likewise, there is no harm in reviewing and discussing the concept(s) involved, and practicing some more before taking the exam again.

We are in a position to discuss the recursion concept, but that should be a new topic. Try posting a question and see what the members respond with. Just don’t post the exam question… We cannot give you the answer or any coaching.

Both of your base case and recursive call should be returned.

in all fairness, I have tried this question several times, and the output is correct, but the test says that it is WRONG. I have looked up the courses, and examples online and they are point to the same solution, but codecademy keeps saying it is incorrect.

1 Like

I’m also stocked on it, codecademy keeps saying it is incorrect. “Did you make a recursive call to `countDownRecursive()` with `count` decremented?”

Change

to:

``````console.log(count);
count--:
countDownRecursive(count);
``````