Bird
Raised Fist0
SASSmarkup~20 mins

Breakpoint variables and maps in SASS - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Breakpoint Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding breakpoint maps in Sass
Given the following Sass map for breakpoints, what is the value of $breakpoints["tablet"]?
SASS
$breakpoints: (
  "mobile": 320px,
  "tablet": 768px,
  "desktop": 1024px
);
A768px
B320px
C1024px
Dnull
Attempts:
2 left
💡 Hint
Look at the key named "tablet" in the map.
📝 Syntax
intermediate
2:00remaining
Correct syntax for defining breakpoint variables
Which of the following Sass code snippets correctly defines a map named $breakpoints with keys "small" and "large" and values 480px and 1200px respectively?
A$breakpoints = (small: 480px, large: 1200px);
B$breakpoints: ["small" => 480px, "large" => 1200px];
C$breakpoints: ("small": 480px, "large": 1200px);
D$breakpoints: {"small": 480px, "large": 1200px};
Attempts:
2 left
💡 Hint
Sass maps use parentheses and colons for key-value pairs.
❓ selector
advanced
2:00remaining
Using breakpoint maps in media queries
Given the breakpoint map below, which Sass code correctly applies styles only for screens wider than the "desktop" breakpoint?
SASS
$breakpoints: (
  "mobile": 320px,
  "tablet": 768px,
  "desktop": 1024px
);
A@media (min-width: $breakpoints["desktop"]) { .container { width: 100%; } }
B@media (min-width: map-get($breakpoints, "desktop")) { .container { width: 100%; } }
C@media (min-width: $breakpoints.desktop) { .container { width: 100%; } }
D@media (min-width: map-get($breakpoints.desktop)) { .container { width: 100%; } }
Attempts:
2 left
💡 Hint
Use the Sass function to get values from maps.
❓ layout
advanced
2:00remaining
Responsive layout with breakpoint variables
You want a container to have 100% width on mobile and tablet, but max-width 1200px on desktop and larger. Which Sass code using breakpoint variables achieves this?
SASS
$breakpoints: (
  "mobile": 320px,
  "tablet": 768px,
  "desktop": 1024px
);
A.container { width: 100%; @media (max-width: map-get($breakpoints, "desktop")) { max-width: 1200px; } }
B.container { max-width: 1200px; @media (max-width: map-get($breakpoints, "tablet")) { width: 100%; } }
C.container { width: 100%; max-width: 1200px; }
D.container { width: 100%; @media (min-width: map-get($breakpoints, "desktop")) { max-width: 1200px; } }
Attempts:
2 left
💡 Hint
Use min-width media query for desktop and larger.
❓ accessibility
expert
3:00remaining
Ensuring accessible font scaling with breakpoint maps
You have a Sass map of breakpoints and want to scale font sizes responsively for accessibility. Which approach below correctly uses breakpoint maps and relative units to improve accessibility?
SASS
$breakpoints: (
  "mobile": 320px,
  "tablet": 768px,
  "desktop": 1024px
);
Abody { font-size: 1rem; @media (min-width: map-get($breakpoints, "tablet")) { font-size: 1.125rem; } @media (min-width: map-get($breakpoints, "desktop")) { font-size: 1.25rem; } }
Bbody { font-size: 16px; @media (min-width: map-get($breakpoints, "tablet")) { font-size: 18px; } @media (min-width: map-get($breakpoints, "desktop")) { font-size: 20px; } }
Cbody { font-size: 1em; @media (min-width: map-get($breakpoints, "desktop")) { font-size: 2em; } }
Dbody { font-size: 100%; @media (max-width: map-get($breakpoints, "tablet")) { font-size: 90%; } }
Attempts:
2 left
💡 Hint
Use relative units like rem for better accessibility.

Practice

(1/5)
1. What is the main purpose of using breakpoint variables and maps in Sass?
easy
A. To manage responsive screen sizes clearly and easily
B. To create animations for buttons
C. To add colors to text
D. To write JavaScript inside Sass files

Solution

  1. Step 1: Understand the role of breakpoints

    Breakpoints define screen sizes where styles change for responsiveness.
  2. Step 2: Recognize how variables and maps help

    Using variables and maps organizes these breakpoints for easy updates and clarity.
  3. Final Answer:

    To manage responsive screen sizes clearly and easily -> Option A
  4. Quick Check:

    Breakpoint variables and maps = Manage screen sizes [OK]
Hint: Breakpoints control screen sizes; variables organize them [OK]
Common Mistakes:
  • Thinking breakpoints add colors or animations
  • Confusing Sass with JavaScript functionality
  • Believing maps are for styling text
2. Which of the following is the correct way to define a breakpoint map in Sass?
easy
A. $breakpoints = {small: 480px, medium: 768px, large: 1024px};
B. $breakpoints: (small: 480px, medium: 768px, large: 1024px);
C. breakpoints: [small: 480px, medium: 768px, large: 1024px];
D. $breakpoints: [small => 480px, medium => 768px, large => 1024px];

Solution

  1. Step 1: Recall Sass map syntax

    Sass maps use parentheses with key: value pairs separated by commas.
  2. Step 2: Check each option

    $breakpoints: (small: 480px, medium: 768px, large: 1024px); uses correct syntax with $variable: (key: value, ...); others use invalid symbols or brackets.
  3. Final Answer:

    $breakpoints: (small: 480px, medium: 768px, large: 1024px); -> Option B
  4. Quick Check:

    Sass map syntax = parentheses and colons [OK]
Hint: Sass maps use parentheses and colons, not brackets or equals [OK]
Common Mistakes:
  • Using = instead of : for variable assignment
  • Using square brackets instead of parentheses
  • Using => instead of : inside maps
3. Given the Sass code:
$breakpoints: (mobile: 480px, tablet: 768px, desktop: 1024px);

.container {
  @media (min-width: map-get($breakpoints, tablet)) {
    width: 80%;
  }
}

What will be the minimum screen width for the media query?
medium
A. 768px
B. 480px
C. 1024px
D. 640px

Solution

  1. Step 1: Identify the map key used

    The media query uses map-get($breakpoints, tablet), so it looks for 'tablet' key.
  2. Step 2: Find the value for 'tablet'

    In the map, 'tablet' corresponds to 768px.
  3. Final Answer:

    768px -> Option A
  4. Quick Check:

    map-get($breakpoints, tablet) = 768px [OK]
Hint: Look up the key in the map to find the breakpoint value [OK]
Common Mistakes:
  • Confusing keys and values in the map
  • Assuming default pixel values instead of map values
  • Mixing up 'mobile' and 'tablet' keys
4. What is wrong with this Sass code snippet?
$breakpoints: (small: 480px, medium: 768px);

@media (min-width: map-get($breakpoints, large)) {
  .box { width: 100%; }
}
medium
A. The variable $breakpoints is not defined
B. The map-get function is used incorrectly
C. The media query syntax is invalid
D. The key 'large' does not exist in the $breakpoints map

Solution

  1. Step 1: Check keys in the $breakpoints map

    The map only has 'small' and 'medium' keys, no 'large'.
  2. Step 2: Understand map-get behavior

    Using map-get with a missing key returns null, causing invalid media query.
  3. Final Answer:

    The key 'large' does not exist in the $breakpoints map -> Option D
  4. Quick Check:

    Missing map key causes error [OK]
Hint: Verify map keys before using map-get [OK]
Common Mistakes:
  • Assuming map-get works with any key
  • Ignoring missing keys causing errors
  • Thinking media query syntax is wrong
5. You want to add a new breakpoint 'xl' at 1280px to this Sass map:
$breakpoints: (sm: 480px, md: 768px, lg: 1024px);

Which is the correct way to update the map and use it in a media query for 'xl'?
hard
A. $breakpoints: append($breakpoints, (xl: 1280px)); @media (min-width: map-get($breakpoints, xl)) { .content { padding: 2rem; } }
B. $breakpoints: (xl: 1280px); @media (min-width: map-get($breakpoints, xl)) { .content { padding: 2rem; } }
C. $breakpoints: map-merge($breakpoints, (xl: 1280px)); @media (min-width: map-get($breakpoints, xl)) { .content { padding: 2rem; } }
D. $breakpoints: (sm: 480px, md: 768px, lg: 1024px xl: 1280px); @media (min-width: map-get($breakpoints, xl)) { .content { padding: 2rem; } }

Solution

  1. Step 1: Understand how to add to existing map

    Use map-merge to add new key-value pairs without overwriting the whole map.
  2. Step 2: Check each option

    append() is invalid for maps; reassigning only 'xl' overwrites and loses prior keys; missing comma between 'lg' and 'xl' causes syntax error; map-merge correctly adds 'xl' to the existing map.
  3. Final Answer:

    $breakpoints: map-merge($breakpoints, (xl: 1280px)); @media (min-width: map-get($breakpoints, xl)) { .content { padding: 2rem; } } -> Option C
  4. Quick Check:

    Use map-merge to add keys safely [OK]
Hint: Use map-merge to add keys without losing existing map [OK]
Common Mistakes:
  • Overwriting the whole map instead of merging
  • Using append which is invalid for maps
  • Missing commas between key-value pairs in maps
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard