Challenge - 5 Problems
Sass List Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate2:00remaining
What is the output of this Sass code using list.nth?
Consider the following Sass code snippet:
What color will be applied to the
$colors: red, green, blue, yellow;
$second-color: list.nth($colors, 2);
.result {
color: $second-color;
}What color will be applied to the
.result class?SASS
$colors: red, green, blue, yellow; $second-color: list.nth($colors, 2); .result { color: $second-color; }
Attempts:
2 left
💡 Hint
Remember that list.nth uses 1-based indexing in Sass lists.
✗ Incorrect
The list $colors has items: red (1), green (2), blue (3), yellow (4). list.nth($colors, 2) returns the second item, which is green.
🧠 Conceptual
intermediate2:00remaining
How many items does this Sass list contain?
Given the Sass list:
What is the result of
$my-list: 10px 20px 30px 40px;
What is the result of
list.length($my-list)?SASS
$my-list: 10px 20px 30px 40px; $length: list.length($my-list); .result { width: $length * 1rem; }
Attempts:
2 left
💡 Hint
Count the number of space-separated items in the list.
✗ Incorrect
The list has four items: 10px, 20px, 30px, and 40px. So list.length returns 4.
❓ selector
advanced2:00remaining
Which option correctly appends an item to a Sass list?
You want to add the value
Which option produces the correct new list?
purple to the end of the list $colors: red, green, blue; using the Sass list module.Which option produces the correct new list?
SASS
$colors: red, green, blue; $new-colors: /* your code here */; .result { content: inspect($new-colors); }
Attempts:
2 left
💡 Hint
Check the official Sass list module function names for adding items.
✗ Incorrect
The correct function to add an item to the end of a list is list.append(). list.push(), list.add(), and list.insert() do not exist or have different signatures.
❓ layout
advanced2:00remaining
What is the visual result of this Sass code using list.join?
Given these Sass variables:
What margin values will the
$list1: 1rem 2rem 3rem;
$list2: 4rem 5rem;
$joined: list.join($list1, $list2, comma);
.box {
margin: $joined;
}What margin values will the
.box class have in the compiled CSS?SASS
$list1: 1rem 2rem 3rem; $list2: 4rem 5rem; $joined: list.join($list1, $list2, comma); .box { margin: $joined; }
Attempts:
2 left
💡 Hint
The third argument to list.join controls the separator between lists.
✗ Incorrect
list.join with the separator 'comma' joins the two lists with commas between all items, so the margin property will have comma-separated values.
❓ accessibility
expert3:00remaining
Which Sass list operation helps improve accessibility by managing focus order?
You have a list of focusable elements in Sass representing tab order:
You want to insert a new element
Which Sass list module function correctly inserts
$focus-order: header, main, footer;
You want to insert a new element
nav between header and main to improve keyboard navigation.Which Sass list module function correctly inserts
nav at position 2?SASS
$focus-order: header, main, footer; $new-focus-order: /* your code here */;
Attempts:
2 left
💡 Hint
Think about how to add an item at a specific position in a list.
✗ Incorrect
list.insert allows inserting an item at a specific index. Here, inserting 'nav' at position 2 places it between 'header' and 'main'. list.append adds at the end, list.prepend at the start, and list.nth only retrieves an item.