typeover
curriculum

Curriculum Basics Conditionals (if and switch) exercise 2 · mcq

Conditionals (if and switch)

TypeScript chains conditions with else if. Zig keeps the same shape — else if, two words, with the same parenthesised condition. Pick the Zig translation.

TypeScript reference
Pick the idiomatic Go translation

About this theme

Zig's if looks like TypeScript's: parens around the condition, optional braces around the body. The catch: Zig has no truthy values — the condition must be bool. switch is an expression in Zig (not a statement), so it can be assigned directly. The TS reflex matches Zig here more cleanly than it matches Go.