Recall & Review
beginner
What is the
sass:map module used for?The
sass:map module provides functions to work with maps in Sass, like adding, removing, or getting values by keys.Click to reveal answer
beginner
How do you get a value from a Sass map?
Use
map.get($map, $key) to retrieve the value for a specific key in a map.Click to reveal answer
beginner
What does
map.has-key($map, $key) do?It checks if the map contains the given key and returns
true or false.Click to reveal answer
intermediate
How can you add or update a key-value pair in a Sass map?
Use
map.set($map, $key, $value) to add a new pair or update an existing key's value.Click to reveal answer
beginner
What happens if you try to get a key that does not exist in a Sass map?
The
map.get function returns null if the key is not found in the map.Click to reveal answer
Which function checks if a key exists in a Sass map?
✗ Incorrect
map.has-key() returns true if the key exists in the map, otherwise false.
How do you add a new key-value pair to a Sass map?
✗ Incorrect
map.set() adds or updates a key-value pair in a Sass map.
What does
map.get($map, $key) return if the key is missing?✗ Incorrect
If the key is not found, map.get() returns null.
Which module must you import to use Sass map functions?
✗ Incorrect
The sass:map module contains all map-related functions.
How do you remove a key from a Sass map?
✗ Incorrect
map.remove($map, $key) removes the key and its value from the map.
Explain how to check if a key exists in a Sass map and retrieve its value safely.
Think about first checking the key, then getting the value.
You got /3 concepts.
Describe how to add a new key-value pair to a Sass map and update an existing key's value.
Remember Sass maps are immutable, so you get a new map back.
You got /3 concepts.