Challenge - 5 Problems
Variable Arguments Mastery
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 mixin usage?
Given the following SASS code, what CSS will be generated?
@mixin box-shadow($shadows...) {
-webkit-box-shadow: $shadows;
box-shadow: $shadows;
}
.box {
@include box-shadow(2px 2px 5px #333, inset 0 0 10px #666);
}SASS
@mixin box-shadow($shadows...) { -webkit-box-shadow: $shadows; box-shadow: $shadows; } .box { @include box-shadow(2px 2px 5px #333, inset 0 0 10px #666); }
Attempts:
2 left
💡 Hint
Remember that variable arguments in SASS are treated as a list and when used directly, they are joined by commas.
✗ Incorrect
The variable argument $shadows... collects all passed arguments as a list. When used directly in properties, the list items are joined by commas, producing multiple shadows separated by commas in CSS.
🧠 Conceptual
intermediate1:30remaining
What type is the variable argument inside a SASS mixin?
In SASS, when you define a mixin with variable arguments like
$args..., what type does $args have inside the mixin?Attempts:
2 left
💡 Hint
Think about how SASS collects multiple arguments passed to a mixin.
✗ Incorrect
Variable arguments in SASS mixins are collected as a list. This allows you to iterate or join them as needed.
❓ selector
advanced2:00remaining
Which option correctly applies variable arguments in a nested selector?
Consider this SASS mixin that applies multiple colors as shadows. Which option correctly uses variable arguments to apply all shadows inside a nested selector?
@mixin multi-shadow($shadows...) {
.shadowed {
box-shadow: $shadows;
}
}SASS
@mixin multi-shadow($shadows...) { .shadowed { box-shadow: $shadows; } }
Attempts:
2 left
💡 Hint
Variable arguments accept multiple comma-separated values.
✗ Incorrect
Option D passes two separate shadow values separated by a comma, which matches the variable argument syntax. Option D passes a single list as one argument, which is not unpacked. Option D misses commas, causing syntax error. Option D passes too many separate arguments that do not form valid shadows.
❓ layout
advanced2:00remaining
What CSS layout is produced by this SASS mixin with variable arguments?
Given this SASS mixin that sets multiple margin values using variable arguments, what is the resulting CSS?
@mixin set-margins($values...) {
margin: $values;
}
.box {
@include set-margins(1rem, 2rem, 3rem, 4rem);
}SASS
@mixin set-margins($values...) { margin: $values; } .box { @include set-margins(1rem, 2rem, 3rem, 4rem); }
Attempts:
2 left
💡 Hint
CSS margin property expects space-separated values, not commas.
✗ Incorrect
SASS variable arguments are joined by commas by default, but CSS margin expects space-separated values. SASS automatically converts the list to space-separated values when used in margin property, so the output is margin: 1rem 2rem 3rem 4rem; without commas.
❓ accessibility
expert2:30remaining
How can variable arguments in SASS mixins help improve accessibility in responsive design?
You want to create a SASS mixin that accepts any number of padding values for different screen sizes to improve spacing for accessibility. Which approach best uses variable arguments to achieve this?
Attempts:
2 left
💡 Hint
Think about how variable arguments can handle flexible input for multiple cases.
✗ Incorrect
Variable arguments allow passing any number of padding values. Inside the mixin, you can loop through these values and apply them to different media queries, making the design responsive and accessible by adjusting spacing per screen size.