Challenge - 5 Problems
Sass Math 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 the
ceil() function?Consider the following Sass code snippet:
$value: 4.3;
$result: ceil($value);
body {
font-size: #{$result}rem;
}What will be the computed font-size in the rendered CSS?SASS
$value: 4.3; $result: ceil($value); body { font-size: #{$result}rem; }
Attempts:
2 left
💡 Hint
The
ceil() function rounds a number up to the nearest whole number.✗ Incorrect
The
ceil() function rounds 4.3 up to 5, so the font-size becomes 5rem.🧠 Conceptual
intermediate1:30remaining
Which Sass built-in math function returns the absolute value?
You want to get the positive value of a number in Sass, regardless if it is negative or positive. Which function should you use?
Attempts:
2 left
💡 Hint
Think about the function that removes the sign from a number.
✗ Incorrect
The
abs() function returns the absolute (positive) value of a number.❓ rendering
advanced2:30remaining
What CSS does this Sass code produce using
min() and max()?Given this Sass code:
$width1: 100px;
$width2: 150px;
$width3: 120px;
.container {
width: min(max($width1, $width3), $width2);
}What is the final width value in the compiled CSS?SASS
$width1: 100px; $width2: 150px; $width3: 120px; .container { width: min(max($width1, $width3), $width2); }
Attempts:
2 left
💡 Hint
First find the max between $width1 and $width3, then find the min between that result and $width2.
✗ Incorrect
max(100px, 120px) is 120px; min(120px, 150px) is 120px, so width is 120px.
❓ selector
advanced1:30remaining
Which Sass function rounds a number to the nearest integer?
You want to round a decimal number to the nearest whole number in Sass. Which function will do this?
Attempts:
2 left
💡 Hint
This function rounds up or down depending on the decimal part.
✗ Incorrect
The
round() function rounds a number to the nearest integer.❓ accessibility
expert3:00remaining
How can Sass math functions help improve accessibility in responsive typography?
You want to create a responsive font size that never goes below 1rem and never above 2rem, scaling smoothly between viewport widths. Which Sass math functions help enforce these limits?
Attempts:
2 left
💡 Hint
Think about which function picks the bigger or smaller value.
✗ Incorrect
Using max() ensures the font size does not go below the minimum, and min() ensures it does not exceed the maximum, helping maintain readable text sizes for accessibility.