Recursion is a major tool in the toolbox of the software engineer.
It can allow to describe a problem from a different perspective.
In the context of Functional Programming this is also a major trick to avoid using mutable variables.
This is a very basic example to be able to understand the concept of recursion fully. In the future, we will see more complex application of recursion.
To build a successful recursion, you need several things:
loopfunction is called inside of itself.
loopis called, it is called with modified arguments.
The most famous example of recursion in books are always
Fibonacci. I would love to see your implementation, feel free to submit a Scastie link in the comment section or on Discord.