Curriculum Basics while and for exercise 1 · mcq
while and for
TypeScript writes while (cond) { ... }. Zig keeps the parens
and the braces. Pick the Zig translation.
TypeScript reference
About this theme
Zig has while (cond) { ... } for condition-driven loops and for (slice) |item| { ... } for iteration. The C-style three-clause for (init; cond; step) is gone — its replacement is while (cond) : (step) { ... } (note the colon-continuation syntax for the step expression). The TS for...of reflex maps directly to Zig's for (...) |item|.