While loops

Repeat while a condition is true.

Rain uses while (condition) body: the condition must be in parentheses.

Countdown

Repeat the body while the condition stays true. Update loop variables inside the body.

Countdown
var n = 3;
while (n > 0) {
  print n;
  n = n - 1;
}
output
3
2
1