Challenge - 5 Problems
Map-Get Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate2:00remaining
What is the output of this Sass code using map-get?
Given the Sass map and the code below, what color will be assigned to
background-color?SASS
$colors: (primary: #ff0000, secondary: #00ff00, accent: #0000ff); .my-class { background-color: map-get($colors, secondary); }
Attempts:
2 left
💡 Hint
Remember that map-get retrieves the value for the given key in the map.
✗ Incorrect
The map $colors has the key 'secondary' with value #00ff00, so map-get returns #00ff00.
🧠 Conceptual
intermediate2:00remaining
What happens if the key does not exist in the map?
Consider this Sass code snippet. What will be the value of
color in the CSS output?SASS
$theme-colors: (light: #eee, dark: #333); .text { color: map-get($theme-colors, medium); }
Attempts:
2 left
💡 Hint
If the key is missing, map-get returns null.
✗ Incorrect
Since 'medium' is not a key in $theme-colors, map-get returns null, so color is null in CSS.
❓ selector
advanced2:30remaining
Which option correctly accesses a nested map value with map-get?
Given the nested map below, which option correctly gets the value
#123456?SASS
$palette: ( theme1: (primary: #abcdef, secondary: #fedcba), theme2: (primary: #123456, secondary: #654321) );
Attempts:
2 left
💡 Hint
Use map-get twice to access nested maps.
✗ Incorrect
You first get the nested map for 'theme2', then get 'primary' from that nested map.
❓ layout
advanced2:30remaining
What CSS output results from this Sass map-get usage in a grid layout?
Given the Sass code below, what is the final CSS for the grid container's
grid-template-columns?SASS
$grid-settings: (columns: 3, gap: 1rem); .container { display: grid; grid-template-columns: repeat(map-get($grid-settings, columns), 1fr); gap: map-get($grid-settings, gap); }
Attempts:
2 left
💡 Hint
map-get returns the value for the key, which is used inside repeat() and gap.
✗ Incorrect
map-get($grid-settings, columns) returns 3, and map-get($grid-settings, gap) returns 1rem, so the CSS is as in option C.
❓ accessibility
expert3:00remaining
How can map-get help improve accessibility in theming?
Consider a Sass map storing color themes for accessibility. Which approach correctly uses map-get to apply a high-contrast color for better readability?
SASS
$accessibility-colors: (normal: #333, high-contrast: #000000); .text { color: map-get($accessibility-colors, high-contrast); }
Attempts:
2 left
💡 Hint
High contrast colors help users with vision difficulties read text better.
✗ Incorrect
Using map-get to select the 'high-contrast' color #000000 ensures text is very dark and readable, improving accessibility.