0
0
SASSmarkup~20 mins

Arithmetic operations in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass Arithmetic Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2: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;
A2rem
B2rem / 5rem
C2 (unitless)
D2
Attempts:
2 left
💡 Hint
Division of two values with the same unit results in a unitless number.
🧠 Conceptual
intermediate
2: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;
A$padding / $margin
B$margin - 0.5em
C$padding + 10px
D$padding * 2
Attempts:
2 left
💡 Hint
Sass does not allow division between values with different units without explicit handling.
rendering
advanced
2: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;
}
Awidth: 10rem;
Bwidth: 12rem + 2rem;
Cwidth: 12rem 2rem;
Dwidth: 12rem;
Attempts:
2 left
💡 Hint
Remember to perform multiplication before addition and units must be compatible.
selector
advanced
2: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;
Amargin: $padding / 2;
Bmargin: $padding / 2px;
Cmargin: $padding * 0.5px;
Dmargin: $padding - 20px;
Attempts:
2 left
💡 Hint
Dividing a length by a number keeps the unit; multiplying by a length unit requires care.
accessibility
expert
3: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?
Afont-size: 1rem + 100vw / 680 * 1rem;
Bfont-size: calc(1rem + (100vw - 320px) / 680 * 1rem);
Cfont-size: 1rem * 100vw / 680 + 1rem;
Dfont-size: calc(1rem * 100vw / 680 + 1rem);
Attempts:
2 left
💡 Hint
Use calc() with proper parentheses and units for responsive scaling.