Put a score in a Map and read it back.
Acceptance criteria
- 1.#out should show 90.
JavaScript Tutorial · JavaScript Map & Set
These 10 tasks go with the JavaScript Map chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “A Map stores key and value pairs where the key can be any type.” Read the chapter.
1.Store and read a valueexercise · easy · 10 min
Put a score in a Map and read it back.
Passes when: #out should show 90.
2.Count the entriesexercise · easy · 10 min · practice plan
Report how many entries the Map holds.
Passes when: #out should show 2.
3.Use a number as a keyexercise · easy · 10 min · practice plan
Store a value under a numeric key and read it back.
Passes when: #out should show a number key.
4.Remove an entryexercise · easy · 10 min · practice plan
Delete an entry and report whether it is still there.
Passes when: #out should show gone.
5.Build from an array of pairsexercise · medium · 10 min · practice plan
Create a Map from pairs and read one value.
Passes when: #out should show 95.
6.Fix the object used for a numeric keybug fix · easy · 8 min
An object turns every key into a string.
Passes when: #out should show a number key.
7.Fix size called as a methodbug fix · easy · 8 min · practice plan
size is a property, not a method.
Passes when: #out should show 2.
8.Fix bracket access on a Mapbug fix · easy · 8 min · practice plan
A Map is read with get, not with square brackets.
Passes when: #out should show 90.
9.Fix the flat array passed inbug fix · easy · 8 min · practice plan
A Map is built from pairs, not a flat list.
Passes when: #out should show 95.
10.Fix delete used with the valuebug fix · easy · 8 min · practice plan
delete takes the key, not the value.
Passes when: #out should show gone.
Between them these tasks cover Map, set and get and size.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.