이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
while repeats
while (test) { ... }runs again and again, as long as the test staystrue.- It checks the test before each pass — so the body might run zero times.

English
let n = 1;
while (n <= 3) {
console.log(n); // → 1, then 2, then 3
n++;
}
English
Make progress every pass
- Something inside must move the test toward
false. - If nothing changes, the loop never stops — an infinite loop (the Stop button saves you).
English
let n = 1;
while (n < 50) {
n = n * 2; // 2, 4, 8, 16, 32, 64 — then stop
}
console.log(n); // → 64
탐색하기
Each pass doubles n
while re-checks its test each pass. n must change, or it runs forever.
English
Common mistakes
- Change the condition inside the loop, or it runs forever.
- A
whilechecks its condition first, so it may run zero times.
English
Now you try
- Use a
whileloop. - Press Check answer to test it.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
let n = 3. Use a while loop to count 아래로: log 3, 2, 1, one per line.
출력을 보려면 '실행'을 클릭하세요.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
let n = 1. While n is 16 or less, log n then double it. Output should be 1, 2, 4, 8, 16.
출력을 보려면 '실행'을 클릭하세요.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Use a while loop to add up 1 부터 4, then log the total (it is 10).
출력을 보려면 '실행'을 클릭하세요.