Challenge - 5 Problems
Sass Return 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 function?
Consider the following Sass function that uses
@return. What will be the value of $result after compilation?SASS
@function double($n) { @return $n * 2; } $result: double(5);
Attempts:
2 left
💡 Hint
The function returns the input number multiplied by 2.
✗ Incorrect
The function
double takes a number and returns it multiplied by 2 using @return. So, double(5) returns 10.🧠 Conceptual
intermediate2:00remaining
What happens if a Sass function has no
@return statement?In Sass, what is the result when a function does not include an
@return statement?SASS
@function noReturn() { $x: 5; // no return here } $value: noReturn();
Attempts:
2 left
💡 Hint
Sass functions must explicitly return a value with @return.
✗ Incorrect
If a Sass function does not have an
@return statement, it returns null by default.❓ rendering
advanced2:00remaining
What color will the text be after Sass compilation?
Given this Sass code using a function with
@return, what color will the paragraph text have in the browser?SASS
@function theme-color($mode) { @if $mode == light { @return #333333; } @else if $mode == dark { @return #eeeeee; } @else { @return #000000; } } p { color: theme-color(dark); }
Attempts:
2 left
💡 Hint
Check which color is returned when the mode is 'dark'.
✗ Incorrect
The function returns #eeeeee when the input is 'dark', so the paragraph text color will be light gray (#eeeeee).
❓ selector
advanced2:00remaining
Which Sass function call returns a list with three items?
Given the Sass function below, which call returns a list with exactly three items?
SASS
@function create-list($a, $b, $c) { @return ($a, $b, $c); }
Attempts:
2 left
💡 Hint
The function returns a list of the three parameters passed.
✗ Incorrect
Only calling the function with three arguments returns a list with three items. Other calls have fewer arguments and will cause errors or return fewer items.
❓ accessibility
expert3:00remaining
How can you use Sass functions with
@return to improve accessible color contrast?You want to create a Sass function that returns a text color based on background brightness to ensure good contrast for accessibility. Which function correctly uses
@return to achieve this?Attempts:
2 left
💡 Hint
Make sure every path in the function uses @return to send back a color.
✗ Incorrect
Option A correctly uses @return in both branches to return black or white depending on background brightness, ensuring accessible contrast. Other options miss @return in some branches or have syntax errors.