Challenge - 5 Problems
Sass List Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding the
length() function in Sass listsWhat 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;
Attempts:
2 left
💡 Hint
Think about how many items are in the list $colors.
✗ Incorrect
The
length() function returns the number of items in a list. Here, $colors has 4 items, so the output is 4.📝 Syntax
intermediate2:00remaining
Using
nth() to access list elementsWhat 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;
Attempts:
2 left
💡 Hint
Remember that list indexes in Sass start at 1.
✗ Incorrect
The
nth() function returns the item at the given position. Position 2 in $colors is 'purple'.❓ selector
advanced2:00remaining
What does
index() return when the item is not found?Consider this Sass code:
What will be the output of
$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;
Attempts:
2 left
💡 Hint
Check what
index() returns if the item is missing.✗ Incorrect
The
index() function returns null if the item is not found in the list.❓ layout
advanced2:00remaining
Combining
join() with different separatorsWhat 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;
Attempts:
2 left
💡 Hint
The third argument sets the separator between the two lists.
✗ Incorrect
Using
comma as separator joins the two lists with commas between all items.❓ accessibility
expert2:30remaining
Using
append() with separator and its effect on list typeGiven this Sass code:
What will be the output of
$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;
Attempts:
2 left
💡 Hint
Appending with
space changes the list separator.✗ Incorrect
Appending with
space separator converts the list to space-separated, so the output is 'a b c d'.