Challenge - 5 Problems
Sass Arithmetic 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?
Consider the following Sass code snippet. What will be the computed value of
$result?SASS
$width: 10rem; $height: 5rem; $result: $width / $height;
Attempts:
2 left
💡 Hint
Division of two values with the same unit results in a unitless number.
✗ Incorrect
When dividing two values with the same unit in Sass, the units cancel out, leaving a unitless number. Here, 10rem / 5rem equals 2 without any units.
🧠 Conceptual
intermediate2:00remaining
Which Sass operation will cause an error?
Given the following variables, which operation will cause a Sass error?
SASS
$padding: 20px; $margin: 1.5em;
Attempts:
2 left
💡 Hint
Sass does not allow division between values with different units without explicit handling.
✗ Incorrect
Dividing 20px by 1.5em causes an error because Sass cannot divide values with different units directly.
❓ rendering
advanced2:00remaining
What is the computed CSS output of this Sass snippet?
Given this Sass code, what will be the final CSS value for
width?SASS
$base: 8rem; $scale: 1.25; .container { width: $base * $scale + 2rem; }
Attempts:
2 left
💡 Hint
Remember to perform multiplication before addition and units must be compatible.
✗ Incorrect
Multiplying 8rem by 1.25 gives 10rem, then adding 2rem results in 12rem. Sass computes this fully before output.
❓ selector
advanced2:00remaining
Which Sass selector uses arithmetic to calculate margin correctly?
Which option correctly sets a margin that is half of the padding variable?
SASS
$padding: 40px;
Attempts:
2 left
💡 Hint
Dividing a length by a number keeps the unit; multiplying by a length unit requires care.
✗ Incorrect
Dividing $padding (40px) by 2 results in 20px, which is half the padding. Multiplying by 0.5px would produce px squared, which is invalid.
❓ accessibility
expert3:00remaining
How can Sass arithmetic help improve accessible responsive font sizes?
Which Sass code snippet uses arithmetic to create a font size that scales between 1rem and 2rem based on viewport width, improving accessibility?
Attempts:
2 left
💡 Hint
Use calc() with proper parentheses and units for responsive scaling.
✗ Incorrect
Option B correctly uses calc() with arithmetic to scale font size smoothly between 1rem and 2rem as viewport width changes, enhancing accessibility.