Recursion Quiz (Certified Full Stack Developer Curriculum)

Hey FCC,

There seems to be an error on question 6. I believe the correct answer is being marked incorrect.

> Which of the following options would be an appropriate base case for the given example?
> 
> function countDownToZero(number) {
>   // Base case goes here.
> 
>   console.log(number);
>   countDownToZero(number - 1);
> }
> if (number < 0) {
>   return;
> }
> if (number !== 0) {
>   return;
> }
> if (number === 0) {
>   return;
> }
> 
> if (number > 0) {
>   return;
> }`

Correct me if I’m wrong but I believe the correct answer is “if(number === 0) {
return;
}”.

There’s easy way to check it:

function countDownToZero(number) {
  if (number === 0) {
    return;
  }

  console.log(number);
  countDownToZero(number - 1);
}

And then:

countDownToZero(5)
5
4
3
2
1

What do you think?

Thanks, but I was simply notifying freeCodeCamp’s staff of the error.

You did say to correct you if you’re wrong?

Zero does not end up in the output.

1 Like

I did, I was relying on AI which continued to tell me that number === 0 was the best base case.

Thank you, sorry for misunderstanding.

other reason why it’s not. what happens if you call the function with -1?

It will run indefinitely until a stack overflow.

The fact AI gave me the incorrect answer worries me as in previous quiz’ I have encountered incorrect answers as well and used AI to check my answers.

Don’t use AI, and definitely don’t use it on a quiz.

The nice thing about programming is it’s deterministic and you can simply test this on your own by running the code if you have questions or doubts.

Empirical evidence > fuzzy AI black box logic.

Write code, test it out.

1 Like