> For the complete documentation index, see [llms.txt](https://ysk.snesjhon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ysk.snesjhon.com/javascript/faqs/modulo-operator.md).

# Modulo Operator

I've had a hard time wrapping my head around the `%` operator because it seemed to me to be more in line with division and I couldn't let go of that image. But the way that I'm imagining it now is thinking about it as a remainder when dividing items and the output is the remainder.

I think about it in fingers, how many times does the denominator go into the numerator and what's the remainder.

```bash
5 % 5 === 0
5 % 4 === 1
5 % 3 === 2
5 % 2 === 1
5 % 1 === 0
5 % 0 === NaN
```

This can be used to figure out remainders and what to use in the tail end of something. For example the Repeating Strings problem.
