0
0
SASSmarkup~20 mins

Built-in map functions in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass Map Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What does the following Sass map function return?
Consider this Sass code:
$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);
A(0, 1, 2)
B(primary, secondary, accent)
C(primary: #333, secondary: #666, accent: #f06)
D(#333, #666, #f06)
Attempts:
2 left
💡 Hint
Think about what keys mean in a map: they are the names, not the values.
📝 Syntax
intermediate
2:00remaining
Which option correctly retrieves the value for 'secondary' from a Sass map?
Given this Sass map:
$palette: (primary: #111, secondary: #222, tertiary: #333);

Which code correctly gets the value #222?
SASS
$palette: (primary: #111, secondary: #222, tertiary: #333);
A$palette['secondary']
Bmap-get($palette, 'secondary')
Cmap-get($palette, "secondary")
Dmap-get($palette, secondary)
Attempts:
2 left
💡 Hint
Keys in Sass maps are identifiers, not strings unless quoted.
rendering
advanced
2:00remaining
What color will the button background be after this Sass code compiles?
Given this Sass code:
$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);
}
ARed (#ff0000)
BTransparent
CBlue (#0055ff)
DBlack (#000000)
Attempts:
2 left
💡 Hint
Look at which key is used in map-get for the background color.
🧠 Conceptual
advanced
2: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?
Alength()
Bmap-count()
Cmap-size()
Dmap-keys()
Attempts:
2 left
💡 Hint
Think about the function that measures how many pairs exist.
accessibility
expert
3: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?
ABy storing color names and values in maps, you can easily switch themes and ensure consistent accessible colors.
BSass maps automatically adjust colors for contrast without extra code.
CMaps allow you to write CSS that disables colors for screen readers.
DUsing maps forces all colors to be grayscale, improving accessibility.
Attempts:
2 left
💡 Hint
Think about how organizing colors helps maintain consistent styles.