# Pure Function

*noun*

say it: **“PYOOR FUNGK-shun”** **/pjʊr ˈfʌŋkʃən/**

A function that always gives the same answer for the same inputs and changes nothing outside itself, so you can test it with no setup.

## What is **Pure Function** in JavaScript?

**Pure Function** — A function that produces the same result for the same inputs without changing outside state.

```javascript
function total(price, quantity) {
    return price * quantity;
}
```

## In a sentence

- “I moved the price math into a **pure function** so the tests didn't need a browser.”
- “formatTime is a **pure function**: give it 90 and it returns "1:30" every time, without touching the page.”

Level: Journeyman · [More JavaScript terms at this level](https://www.ask-codey.com/glossary?category=javascript&level=3)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/pure-function
