In Go, you update a value in a map by assigning a new value to an existing key:
scores := map[string]int{}
scores["Alice"] = 95
scores["Bob"] = 87
scores["Alice"] = 99 // update: Alice is now 99
scores["Charlie"] = 72 // add new entry
The bracket operator [] both accesses and creates/updates entries. Assigning to an existing key simply overwrites the old value:
scores["Alice"] = 99 // updates Alice
Assignment
Follow the Coding Tutorial and update Alice's score to 99!
Hint
Use scores["Alice"] = 99.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
