Recursion
JavaScriptLearn to solve problems by having a function call itself. Master the base case, the recursive step, and the classic patterns that show up everywhere.
Your progress
0/11 complete
- 1β‘ 15
Trace the Call Stack Quiz
Watch a recursive call unwind, step by step, before you write one.
- 2β‘ 15
Base Case First Quiz
Every recursion needs a stopping condition β write it before the recursion.
- 3β‘ 35
Countdown
Your first recursive function.
- 4β‘ 35
Factorial
n! = n Γ (n-1) Γ ... Γ 1.
- 5β‘ 40
Sum an Array
Add up numbers without a loop.
- 6β‘ 40
Reverse a String
Flip a string recursively.
- 7β‘ 45
Power
Compute base^exp without **.
- 8β‘ 15
When You Need Two Base Cases Quiz
Some recursions stop on more than one input β and call themselves twice.
- 9β‘ 45
Fibonacci
The nth number in the famous sequence.
- 10β‘ 25
Is It an Array?
Before flattening, learn the one check that decides 'recurse or keep'.
- 11β‘ 55
Flatten Nested Arrays
Crush a nested array into a flat one.