typeover
curriculum

Curriculum Foundations Conditionals & switch exercise 1 · mcq

Conditionals & switch

TypeScript's if wraps the condition in parentheses and allows single-statement bodies without braces. Go does both differently — no parens, braces always. Pick the idiomatic Go translation.

TypeScript reference
Pick the idiomatic Go translation

About this theme

if/else looks familiar — no parentheses, braces required. The one new shape is the short-statement-if: if err := work(); err != nil { ... }. It scopes a temporary to the condition; you'll see this everywhere in Go. switch exists and doesn't fall through by default — closer to TypeScript's switch with implicit break than to C's.