# Recursion

A function calling itself to solve a smaller piece of the same problem.

## What is **Recursion** in JavaScript?

**Recursion** — A function calling itself to solve a smaller piece of the same problem.

```javascript
function countdown(number) {
    if (number === 0) {
        return 0;
    }

    return 1 + countdown(number - 1);
}
```

Level: Journeyman · [More JavaScript terms at this level](https://www.ask-codey.com/glossary/subjects/javascript/journeyman)

Updated: September 27, 2026

## In other subjects

- [Recursion in C#](https://www.ask-codey.com/glossary/recursion-c-sharp)
- [Recursion in Java](https://www.ask-codey.com/glossary/recursion-java)

Source: https://www.ask-codey.com/glossary/recursion-javascript
