typeover
curriculum

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

Variables (const and var)

TypeScript's const and Zig's const look identical, but there's a wrinkle: Zig prefers const as the DEFAULT — every declaration starts as const until you have a reason to make it mutable. Pick the Zig translation for this constant.

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.