Recursive Functions | Sololearn: Learn to code for FREE!

0

Recursive Functions

Can I get explanations on how recursive Functions work with reference to countdown of numbers?

5/15/2021 1:53:39 PM

Kwaku Tutu

4 Answers

New Answer

+4

recursive functions are functions calling themselves... so the first requirement is to have a base case to stop the recursion else you've got a stack overflow error ^^ to countdown numbers recursively, the base case is reached when the count reach zero (or is less than zero). also, the initial count must be passed as argument to the initial call: function countdown(count) { if (count<0) return; console.log(count); countdown(count-1); } countdown(10);

+1

Just see this post 👇👇 https://www.sololearn.com/Discuss/307407/?ref=app

+1

Link opens same discussion. Which one is the relevant answer?

0

https://www.sololearn.com/post/206034/?ref=app