typeover
curriculum

Curriculum Basics Conditionals (if and switch) exercise 4 · fill-word

Conditionals (if and switch)

Fill the missing keyword. The condition's first branch handles the positive case; the second branch should handle every other case. Same keyword as TypeScript and most C-family languages.

TypeScript reference
Fill the blanks →

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.