0
0
SASSmarkup~20 mins

Built-in list functions in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass List Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the length() function in Sass lists
What is the output of the following Sass code snippet?

$colors: red, blue, green, yellow;
$len: length($colors);
@debug $len;
SASS
$colors: red, blue, green, yellow;
$len: length($colors);
@debug $len;
A3
B4
C1
DError: length() only works on strings
Attempts:
2 left
💡 Hint
Think about how many items are in the list $colors.
📝 Syntax
intermediate
2:00remaining
Using nth() to access list elements
What is the value of $second-color after running this Sass code?

$colors: orange, purple, teal;
$second-color: nth($colors, 2);
@debug $second-color;
SASS
$colors: orange, purple, teal;
$second-color: nth($colors, 2);
@debug $second-color;
Apurple
Borange
Cteal
DError: nth() index out of range
Attempts:
2 left
💡 Hint
Remember that list indexes in Sass start at 1.
selector
advanced
2:00remaining
What does index() return when the item is not found?
Consider this Sass code:

$shapes: circle, square, triangle;
$pos: index($shapes, ellipse);
@debug $pos;

What will be the output of @debug $pos;?
SASS
$shapes: circle, square, triangle;
$pos: index($shapes, ellipse);
@debug $pos;
Afalse
B0
Cnull
DError: item not found
Attempts:
2 left
💡 Hint
Check what index() returns if the item is missing.
layout
advanced
2:00remaining
Combining join() with different separators
What is the output of this Sass code?

$list1: 1 2 3;
$list2: 4 5 6;
$joined: join($list1, $list2, comma);
@debug $joined;
SASS
$list1: 1 2 3;
$list2: 4 5 6;
$joined: join($list1, $list2, comma);
@debug $joined;
A1, 2, 3, 4, 5, 6
B1 2 3 4 5 6
CError: join() requires space or comma separator only
D1, 2, 3 4, 5, 6
Attempts:
2 left
💡 Hint
The third argument sets the separator between the two lists.
accessibility
expert
2:30remaining
Using append() with separator and its effect on list type
Given this Sass code:

$base-list: a, b, c;
$new-list: append($base-list, d, space);
@debug $new-list;

What will be the output of @debug $new-list;?
SASS
$base-list: a, b, c;
$new-list: append($base-list, d, space);
@debug $new-list;
AError: append() separator must match list separator
Ba, b, c d
Ca, b, c, d
Da b c d
Attempts:
2 left
💡 Hint
Appending with space changes the list separator.