Challenge - 5 Problems
Sass Map Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
What does the following Sass map function return?
Consider this Sass code:
What is the value of
$colors: (primary: #333, secondary: #666, accent: #f06);
$keys: map-keys($colors);
What is the value of
$keys?SASS
$colors: (primary: #333, secondary: #666, accent: #f06); $keys: map-keys($colors);
Attempts:
2 left
💡 Hint
Think about what keys mean in a map: they are the names, not the values.
✗ Incorrect
The
map-keys() function returns a list of all the keys in the map. Here, the keys are primary, secondary, and accent.📝 Syntax
intermediate2:00remaining
Which option correctly retrieves the value for 'secondary' from a Sass map?
Given this Sass map:
Which code correctly gets the value
$palette: (primary: #111, secondary: #222, tertiary: #333);
Which code correctly gets the value
#222?SASS
$palette: (primary: #111, secondary: #222, tertiary: #333);
Attempts:
2 left
💡 Hint
Keys in Sass maps are identifiers, not strings unless quoted.
✗ Incorrect
In Sass, map keys can be unquoted identifiers. Using
map-get($palette, secondary) correctly retrieves the value. Using quotes treats the key as a string which does not match the unquoted key.❓ rendering
advanced2:00remaining
What color will the button background be after this Sass code compiles?
Given this Sass code:
What color will the button have in the browser?
$theme-colors: (primary: #0055ff, danger: #ff0000);
.btn {
background-color: map-get($theme-colors, danger);
}
What color will the button have in the browser?
SASS
$theme-colors: (primary: #0055ff, danger: #ff0000); .btn { background-color: map-get($theme-colors, danger); }
Attempts:
2 left
💡 Hint
Look at which key is used in map-get for the background color.
✗ Incorrect
The
map-get function retrieves the value for the key danger, which is #ff0000 (red). So the button background will be red.🧠 Conceptual
advanced2:00remaining
Which Sass function returns the number of key-value pairs?
You want to find out how many items are in a Sass map. Which function gives you this number?
Attempts:
2 left
💡 Hint
Think about the function that measures how many pairs exist.
✗ Incorrect
map-size() returns the number of key-value pairs in a Sass map. The other functions do not exist or return different data.❓ accessibility
expert3:00remaining
How can Sass maps help improve accessibility in theming?
You want to create a theme with colors that adapt for better contrast and readability. How can Sass maps assist in this task?
Attempts:
2 left
💡 Hint
Think about how organizing colors helps maintain consistent styles.
✗ Incorrect
Sass maps let you group color values by name. This makes it easy to swap entire color sets for different themes, including high-contrast ones for accessibility. Sass itself does not automatically adjust colors or disable them for screen readers.