From the course: JavaScript: Maps and Sets
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Solution: Maps 2 - JavaScript Tutorial
From the course: JavaScript: Maps and Sets
Solution: Maps 2
(light upbeat music) - [Instructor] In this next challenge, we want to determine if a map has the key of Brandon. So if we look in our test code, we can see that the map has actually been set up for us. So that step has been removed. We just need to see at this point, does that map contain a specific key? So let's go ahead and write out our return statement. And then we need to reference the allUsers map. And we're going to be using the method has to determine if that key exists. And the key that we're looking for is Brandon. I'll mention this in several different videos and lessons, but when it comes to strings in JavaScript, it's really important that the case matches. So it's going to be looking for an exact match for Brandon. If we were looking for Alice, if we passed a lowercase A instead of capital A, it would return false for us. So it's really important to make sure that the casing matches. So here we have, we're returning allUsers, which is our map, and we're checking to see,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
The Map object defined1m 23s
-
(Locked)
Build your Map object with the set method4m 41s
-
(Locked)
Access a value with get3m 51s
-
(Locked)
Does the map have your key?3m 4s
-
(Locked)
Determine map size2m 6s
-
(Locked)
Remove key-value pairs with clear and delete4m 23s
-
(Locked)
Map: Keys and values methods5m 44s
-
(Locked)
Map contents with the entries method2m 32s
-
(Locked)
Loop over a map with forEach2m 38s
-
(Locked)
Group entries with groupBy3m 22s
-
(Locked)
Solution: Maps 12m
-
(Locked)
Solution: Maps 21m 32s
-
-
-
-
-