Key Concepts

Review core concepts you need to learn to master this subject

Base Case of a Recursive Function

function countdown(value) if value is negative or zero print "done" otherwise if value is greater than zero print value call countdown with (value-1)

A recursive function should have a base case with a condition that stops the function from recursing indefinitely. In the example, the base case is a condition evaluating a negative or zero value to be true.

Recursion: Conceptual
Lesson 1 of 1

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo