Understanding How Recursion works

Bobby Valenzuela
6 min readMar 14, 2021

Here’s a function in JavaScript:

const countUp = num =>{    console.log(`counting...${num}`);    countUp(num);
}
countUp(0);

Given that the function calls itself, we can instantly recognize that this code will cause an infinite loop which will log ‘counting …’ and the current number with each…

--

--