While Loops
While loops repeat code as long as a condition is true. Use them when you don't know how many iterations you need.
Basic While Loop
Loading JavaScript Playground...
While vs For
Loading JavaScript Playground...
Do...While Loop
Executes at least once, then checks the condition:
Loading JavaScript Playground...
Infinite Loop Prevention
Loading JavaScript Playground...
Finding Values
Loading JavaScript Playground...
Exercise: Countdown
Create a countdown from 5 to 1:
Loading JavaScript Exercise...
Exercise: Guess the Pattern
Find when a growing number exceeds 1000:
Loading JavaScript Exercise...
Up next · Lesson 18 of 37
Break and Continue
1 min read
17 of 37 lessons done

Ask Byte about this lesson
A private chat about this lesson. Byte has read the whole lesson, answers in seconds, and shows the section each answer comes from. Ask follow-ups in any language.
Questions & Answers
Public questions about this lesson. The AI Tutor answers right away in your language, the FreeAcademy team checks answers, and every learner can read them.

