Curriculum Foundations Loops exercise 1 · mcq
Loops
TypeScript's classic counted loop has three parts in parentheses
separated by semicolons. Go's for keeps the three parts but
drops the parens. Pick the idiomatic Go translation.
TypeScript reference
About this theme
Go has one loop keyword: for. Three shapes:
for i := 0; i < n; i++ { ... }— classic.for cond { ... }— while-style.for { ... }— infinite, exit viabreakorreturn.
No while, no do. continue, break, and labelled breaks behave as you'd expect. The range form is its own theme (next module).