Skip to main content

Nested control flow

A while loop with an if nested inside it — printing even numbers as it walks a range, then reporting the total.

test_v1_compat.tiny
let sum be 0
let i be 1

while i <= 5
if i % 2 == 0
show i
set sum to sum + i
set i to i + 1

show sum

Expected output:

2
4
15