typeover
curriculum

Curriculum Basics Variables (const and var) exercise 1 · mcq

Variables (const and var)

TypeScript declares a mutable binding with let and the type annotation : type between the name and the =. Zig swaps the keyword to var and keeps the annotation position — but with a Zig-specific width (no generic number/boolean). Pick the idiomatic Zig translation.

TypeScript reference
Pick the idiomatic Go translation

About this theme

Zig defaults the other way from TypeScript. const is the default reflex; var is the explicit opt-in when you need to reassign. Type annotations come AFTER the name (var x: i32 = 5), not before, and they're optional when the literal disambiguates. Shadowing across scopes is allowed; redeclaring in the same scope is a compile error.