0
0
SASSmarkup~20 mins

@return statement in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass Return 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 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);
A25
B5
C10
DError: Undefined variable
Attempts:
2 left
💡 Hint
The function returns the input number multiplied by 2.
🧠 Conceptual
intermediate
2: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();
ACompilation error: missing @return statement.
BThe function returns 0 by default.
CThe function returns the last variable assigned, $x (5).
DThe function returns null, so $value is null.
Attempts:
2 left
💡 Hint
Sass functions must explicitly return a value with @return.
rendering
advanced
2: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);
}
AThe text color will be transparent.
BThe text color will be #eeeeee (light gray).
CThe text color will be #000000 (black).
DThe text color will be #333333 (dark gray).
Attempts:
2 left
💡 Hint
Check which color is returned when the mode is 'dark'.
selector
advanced
2: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);
}
Acreate-list(1, 2, 3)
Bcreate-list(1, 2)
Ccreate-list(1)
Dcreate-list()
Attempts:
2 left
💡 Hint
The function returns a list of the three parameters passed.
accessibility
expert
3: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?
A
@function accessible-text-color($bg) {
  @if lightness($bg) > 50% {
    @return #000000;
  } @else {
    @return #ffffff;
  }
}
B
@function accessible-text-color($bg) {
  @if lightness($bg) > 50% {
    #000000;
  } @else {
    @return #ffffff;
  }
}
C
@function accessible-text-color($bg) {
  @if lightness($bg) < 50% {
    @return #000000;
  } @else {
    #ffffff;
  }
}
D
@function accessible-text-color($bg) {
  @return if(lightness($bg) > 50%, #000000, #ffffff);
}
Attempts:
2 left
💡 Hint
Make sure every path in the function uses @return to send back a color.