typeover
curriculum

Curriculum Collections Maps exercise 4 · mcq

Maps

Exercise 3 pinned the trap: missing-key lookup returns the zero value, same as a present-but-zero entry. Pick the idiomatic Go check for "is key name PRESENT in scores?" — the antidote to that trap. TypeScript habit: ``ts if (name in scores) { /* present */ } // or: if (scores[name] !== undefined) { /* present */ } ``

TypeScript reference
Pick the idiomatic Go translation

About this theme

map[K]V. Like a TS Record<K, V> or Map<K, V>. Lookup with comma-ok: v, ok := m[key]. Iteration order is undefined — every range yields a different ordering. Maps are reference types; passing a map to a function shares it.