Skip to content
Justice Tech School

while and do while

while checks first and do while runs at least once.

Example
var n = 3;
while (n > 0) { print(n); n--; }
do { print("once"); } while (false);

Exercise

Run once first.

 { } while (c);

Quiz Test

Which runs the body first?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.