Curriculum Basics Functions exercise 1 · mcq
Functions
TypeScript writes function add(a: number, b: number): number.
Zig drops the function keyword for fn, puts the return type
AFTER the param list (no colon), and uses Zig-specific widths.
Pick the Zig translation.
TypeScript reference
About this theme
Zig functions look like TS with the type annotations shifted: fn name(param: Type) ReturnType { ... }. Visibility is opt-in via pub fn — top-level functions are private by default. Zig has no tuple-return; multi-return uses a struct (the Zig idiom) or out-params. Function-level errors come later in the errors module; here we focus on the value-returning shape.