Skip to main content
← All courses
πŸ”

Recursion

JavaScript

Learn 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

Start β†’ Trace the Call Stack
  1. 1

    Trace the Call Stack Quiz

    Watch a recursive call unwind, step by step, before you write one.

    ⚑ 15
  2. 2

    Base Case First Quiz

    Every recursion needs a stopping condition β€” write it before the recursion.

    ⚑ 15
  3. 3

    Countdown

    Your first recursive function.

    ⚑ 35
  4. 4

    Factorial

    n! = n Γ— (n-1) Γ— ... Γ— 1.

    ⚑ 35
  5. 5

    Sum an Array

    Add up numbers without a loop.

    ⚑ 40
  6. 6

    Reverse a String

    Flip a string recursively.

    ⚑ 40
  7. 7

    Power

    Compute base^exp without **.

    ⚑ 45
  8. 8

    When You Need Two Base Cases Quiz

    Some recursions stop on more than one input β€” and call themselves twice.

    ⚑ 15
  9. 9

    Fibonacci

    The nth number in the famous sequence.

    ⚑ 45
  10. 10

    Is It an Array?

    Before flattening, learn the one check that decides 'recurse or keep'.

    ⚑ 25
  11. 11

    Flatten Nested Arrays

    Crush a nested array into a flat one.

    ⚑ 55