Challenge - 5 Problems
SASS Default Parameter Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate2:00remaining
What is the output CSS of this SASS code with default parameter?
Consider this SASS function with a default parameter. What CSS color will the
.box class have?SASS
@function set-color($color: blue) { @return $color; } .box { color: set-color(); }
Attempts:
2 left
💡 Hint
If no argument is given, the default value is used.
✗ Incorrect
The function uses the default parameter value 'blue' when no argument is passed, so the color is blue.
🧠 Conceptual
intermediate2:00remaining
What happens if you override a default parameter in a mixin?
Given this mixin with a default parameter, what color will the
.alert class have?SASS
@mixin alert-color($color: red) { color: $color; } .alert { @include alert-color(green); }
Attempts:
2 left
💡 Hint
Passing an argument overrides the default value.
✗ Incorrect
The mixin uses the passed argument 'green' instead of the default 'red', so the color is green.
❓ rendering
advanced2:30remaining
What is the rendered CSS output of this nested mixin with default parameters?
Analyze this SASS code with nested mixins and default parameters. What CSS will be generated for
.card?SASS
@mixin border-style($width: 1px, $color: black) { border: $width solid $color; } @mixin card-style($border-width: 2px) { @include border-style($border-width); padding: 1rem; } .card { @include card-style(); }
Attempts:
2 left
💡 Hint
The outer mixin overrides the first default parameter but not the second.
✗ Incorrect
The
card-style mixin passes 2px as the first argument to border-style, so border width is 2px and color uses default black.❓ selector
advanced2:30remaining
Which option shows the correct CSS output for this SASS function with default parameter and conditional?
This SASS function returns a font size based on a parameter with a default. What CSS will
h1 have?SASS
@function font-size($level: 3) { @if $level == 1 { @return 2rem; } @else if $level == 2 { @return 1.5rem; } @else { @return 1rem; } } h1 { font-size: font-size(); }
Attempts:
2 left
💡 Hint
Default parameter is 3, which triggers the else case.
✗ Incorrect
Since the default $level is 3, the else block returns 1rem for font size.
❓ accessibility
expert3:00remaining
How does using default parameter values in SASS mixins improve accessibility and maintainability?
Choose the best explanation of how default parameters in SASS mixins help create accessible and maintainable CSS.
Attempts:
2 left
💡 Hint
Think about how default values help keep styles consistent and predictable.
✗ Incorrect
Default parameters provide fallback values so styles remain consistent and accessible even if no arguments are given, improving maintainability and user experience.