typeover
curriculum

Curriculum Foundations Conditionals & switch exercise 3 · mcq

Conditionals & switch

TypeScript's switch falls through unless you explicitly break out of each case — forget a break and execution drops into the next case (a classic source of bugs). Go reversed this default: each case ends implicitly. 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.