0
0
SASSmarkup~20 mins

Variable arguments in mixins in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Variable Arguments Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2: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);
}
A
.box {
  -webkit-box-shadow: 2px 2px 5px #333, inset 0 0 10px #666;
  box-shadow: 2px 2px 5px #333, inset 0 0 10px #666;
}
B
.box {
  -webkit-box-shadow: (2px 2px 5px #333, inset 0 0 10px #666);
  box-shadow: (2px 2px 5px #333, inset 0 0 10px #666);
}
C
.box {
  -webkit-box-shadow: 2px 2px 5px #333 inset 0 0 10px #666;
  box-shadow: 2px 2px 5px #333 inset 0 0 10px #666;
}
D
.box {
  -webkit-box-shadow: 2px 2px 5px #333;
  box-shadow: 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.
🧠 Conceptual
intermediate
1: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?
AA list containing all passed arguments
BA string concatenation of all arguments
CA map with keys as argument positions
DA single value of the first argument only
Attempts:
2 left
💡 Hint
Think about how SASS collects multiple arguments passed to a mixin.
selector
advanced
2: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;
  }
}
A@include multi-shadow(1px, 1px, 2px, black, 0, 0, 5px, red);
B@include multi-shadow((1px 1px 2px black, 0 0 5px red));
C@include multi-shadow(1px 1px 2px black 0 0 5px red);
D@include multi-shadow(1px 1px 2px black, 0 0 5px red);
Attempts:
2 left
💡 Hint
Variable arguments accept multiple comma-separated values.
layout
advanced
2: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);
}
A
.box {
  margin: 1rem, 2rem, 3rem, 4rem;
}
B
.box {
  margin: 1rem 2rem 3rem 4rem;
}
C
.box {
  margin: (1rem 2rem 3rem 4rem);
}
D
.box {
  margin: 1rem;
  margin: 2rem;
  margin: 3rem;
  margin: 4rem;
}
Attempts:
2 left
💡 Hint
CSS margin property expects space-separated values, not commas.
accessibility
expert
2: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?
AUse variable arguments but apply only the first value for all screen sizes to keep it simple.
BUse fixed padding values inside the mixin and ignore variable arguments for consistency.
CUse a variable argument to accept multiple padding values and apply them inside media queries for different breakpoints.
DAvoid variable arguments and write separate mixins for each screen size.
Attempts:
2 left
💡 Hint
Think about how variable arguments can handle flexible input for multiple cases.