# 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)
}
}
``````

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?â