A list in Sass is a collection of values separated by spaces or commas. It helps group multiple values together for easy use and manipulation.
Click to reveal answer
beginner
How do you create a comma-separated list in Sass?
You create a comma-separated list by writing values separated by commas, like: $colors: red, green, blue;
Click to reveal answer
intermediate
What does the nth() function do in Sass lists?
The nth() function returns the value at a specific position in a list. For example, nth($list, 2) gives the second item.
Click to reveal answer
intermediate
How can you add a value to the end of a Sass list?
Use the append() function. For example, append($list, new-value) adds new-value to the end of $list. By default, it appends with a space separator unless a third argument specifies otherwise.
Click to reveal answer
advanced
What is the difference between space-separated and comma-separated lists in Sass?
Space-separated lists use spaces between values and behave like multiple arguments. Comma-separated lists use commas and keep values grouped distinctly. Some functions treat them differently.
Click to reveal answer
How do you access the third item in a Sass list named $my-list?
Aget($my-list, 3)
Bnth($my-list, 3)
C$my-list[3]
Ditem($my-list, 3)
✗ Incorrect
The nth() function is used to get the item at a specific position in a Sass list.
Which function adds a value to the end of a Sass list?
Aappend()
Binsert()
Cadd()
Dpush()
✗ Incorrect
The append() function adds a new value to the end of a list in Sass.
What separator does this list use? $list: 10px 20px 30px;
ASpace-separated
BSemicolon-separated
CComma-separated
DColon-separated
✗ Incorrect
Values separated by spaces form a space-separated list in Sass.
If you want to keep values grouped distinctly, which list separator should you use?
ASpace
BSemicolon
CComma
DSlash
✗ Incorrect
Comma-separated lists keep values grouped distinctly in Sass.
What will length(10px, 20px, 30px) return?
A0
B1
C3
DError
✗ Incorrect
The length() function requires a list variable, not separate arguments. Passing separate values causes an error.
Explain how to create and access values in a Sass list.
Think about how you group items in a shopping list and how you pick one item by position.
You got /3 concepts.
Describe how to add a new value to an existing Sass list and why list separators matter.
Imagine adding a new ingredient to a recipe list and how you separate ingredients.
You got /3 concepts.
Practice
(1/5)
1. What does a list in Sass represent?
easy
A. A type of selector
B. A single color value
C. A CSS property name
D. A group of multiple values stored together
Solution
Step 1: Understand the concept of lists in Sass
Lists in Sass are used to group multiple values together for easy reuse.
Step 2: Identify the correct description
'A group of multiple values stored together' correctly describes a Sass list.
Final Answer:
A group of multiple values stored together -> Option D
Quick Check:
List = group of values [OK]
Hint: Lists hold multiple values separated by commas or spaces [OK]
Common Mistakes:
Thinking a list is a single value
Confusing lists with CSS properties
Assuming lists are selectors
2. Which of the following is the correct syntax for a list with three colors in Sass?
easy
A. $colors: red, green, blue;
B. $colors: (red, green, blue);
C. $colors: red, green blue;
D. $colors: [red, green, blue];
Solution
Step 1: Recall Sass list syntax
Sass lists use commas or spaces to separate values without parentheses or brackets.
Step 2: Identify the correct syntax
$colors: red, green, blue; uses commas correctly without extra characters, which is valid Sass list syntax.
Final Answer:
$colors: red, green, blue; -> Option A
Quick Check:
List syntax uses commas or spaces [OK]
Hint: Use commas or spaces without brackets for lists [OK]
Common Mistakes:
Using parentheses like tuples
Using square brackets like arrays
Missing commas when needed
3. Given the Sass list $sizes: 10px 20px 30px;, what does nth($sizes, 2) return?
medium
A. 10px
B. 30px
C. 20px
D. Error
Solution
Step 1: Understand nth() function
nth() returns the item at the given position (1-based) in the list.
Step 2: Apply nth() to the list
The list is 10px (1), 20px (2), 30px (3). nth($sizes, 2) returns the second item: 20px.
Final Answer:
20px -> Option C
Quick Check:
nth() returns item at position [OK]
Hint: nth(list, n) gets the nth item starting at 1 [OK]
Common Mistakes:
Using zero-based index instead of one-based
Confusing nth() with length()
Expecting an error for valid index
4. What is wrong with this Sass code?
$list: 1, 2, 3;
width: nth($list 2);
medium
A. Missing comma between $list and 2 in nth()
B. nth() cannot be used with numbers
C. List must use spaces, not commas
D. nth() requires three arguments
Solution
Step 1: Check nth() function syntax
nth() requires two arguments separated by a comma: the list and the index.
Step 2: Identify the syntax error
The code uses nth($list 2) missing a comma between $list and 2, causing a syntax error.
Final Answer:
Missing comma between $list and 2 in nth() -> Option A
Quick Check:
nth() needs comma-separated arguments [OK]
Hint: Separate nth() arguments with a comma [OK]
Common Mistakes:
Omitting comma between arguments
Using wrong number of arguments
Confusing nth() with other functions
5. How can you get the number of items in the Sass list $fonts: 'Arial', 'Helvetica', 'Sans-serif';?
hard
A. Using nth($fonts)
B. Using length($fonts)
C. Using size($fonts)
D. Using count($fonts)
Solution
Step 1: Recall function to get list length
Sass provides the length() function to return the number of items in a list.
Step 2: Match the function to the list
Applying length($fonts) returns 3, the number of font names in the list.
Final Answer:
Using length($fonts) -> Option B
Quick Check:
length() returns list size [OK]
Hint: Use length() to count list items [OK]
Common Mistakes:
Using count() which is not a Sass function
Using size() which is invalid
Using nth() without index
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.