# Repeating with while

A while loop repeats a block of code for as long as its condition stays true, which fits any job where you can't know in advance how many times it will take, as long as something inside the loop lets it end.

![Cheat sheet: Repeating with while](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/10/349e3c9b998647eb8975696f31b79c5b.webp)

- Category: JavaScript
- Level: Novice
- Tags: Increment Operator (javascript), Infinite Loop (javascript), Iteration, JavaScript, while Loop (javascript)
- Updated: November 1, 2026

Source: https://www.ask-codey.com/cheat-sheets/javascript-loops-while-cheat-sheet
