Recall & Review
beginner
What does the
map-get() function do in Sass?It retrieves the value associated with a specific key from a Sass map.
Click to reveal answer
beginner
How do you access the color value for the key
primary in this Sass map?<br>$colors: (primary: #ff0000, secondary: #00ff00);
Use
map-get($colors, primary) to get #ff0000.Click to reveal answer
intermediate
What happens if you use
map-get() with a key that does not exist in the map?It returns
null, meaning no value is found for that key.Click to reveal answer
intermediate
True or False:
map-get() can be used to access nested maps inside a Sass map.True. You can use
map-get() multiple times to access nested values.Click to reveal answer
intermediate
Why is using
map-get() better than using list indexing for Sass maps?Because maps are key-value pairs and unordered,
map-get() accesses values by key safely, unlike list indexing which depends on order.Click to reveal answer
What is the correct syntax to get the value for key
font-size from a Sass map named $settings?✗ Incorrect
The correct function is
map-get() with the map and key as arguments.If
map-get($colors, accent) returns null, what does it mean?✗ Incorrect
A
null return means the key was not found in the map.Can
map-get() be used to access values inside nested maps?✗ Incorrect
You can chain
map-get() calls to reach nested map values.Which of these is NOT a valid key type for Sass maps?
✗ Incorrect
Functions cannot be used as keys in Sass maps.
Why should you prefer
map-get() over list indexing when working with Sass maps?✗ Incorrect
Maps do not have order, so accessing by key with
map-get() is reliable.Explain how to use
map-get() to retrieve a value from a Sass map. Include an example.Think about how you ask a friend for a specific item from a labeled box.
You got /4 concepts.
Describe what happens if you try to get a value from a Sass map using a key that does not exist.
What does it mean when you look for something in a box but it’s not there?
You got /3 concepts.