Recursive Functions | Sololearn: Learn to code for FREE!


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


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);


Just see this post 👇👇


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