Bird
Raised Fist0
SASSmarkup~20 mins

sass:list module - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Sass List Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
What is the output of this Sass code using list.nth?
Consider the following Sass code snippet:
$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;
}
Ayellow
Bblue
Cred
Dgreen
Attempts:
2 left
💡 Hint
Remember that list.nth uses 1-based indexing in Sass lists.
🧠 Conceptual
intermediate
2:00remaining
How many items does this Sass list contain?
Given the Sass list:
$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;
}
A4
B1
C0
D5
Attempts:
2 left
💡 Hint
Count the number of space-separated items in the list.
❓ selector
advanced
2:00remaining
Which option correctly appends an item to a Sass list?
You want to add the value 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);
}
Alist.append($colors, purple)
Blist.push($colors, purple)
Clist.insert($colors, purple)
Dlist.add($colors, purple)
Attempts:
2 left
💡 Hint
Check the official Sass list module function names for adding items.
❓ layout
advanced
2:00remaining
What is the visual result of this Sass code using list.join?
Given these Sass variables:
$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;
}
Amargin: 1rem 2rem 3rem 4rem 5rem;
Bmargin: 1rem 2rem 3rem, 4rem 5rem;
Cmargin: 1rem, 2rem, 3rem, 4rem, 5rem;
Dmargin: 1rem, 2rem, 3rem 4rem, 5rem;
Attempts:
2 left
💡 Hint
The third argument to list.join controls the separator between lists.
❓ accessibility
expert
3:00remaining
Which Sass list operation helps improve accessibility by managing focus order?
You have a list of focusable elements in Sass representing tab order:
$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 */;
Alist.prepend($focus-order, nav)
Blist.insert($focus-order, nav, 2)
Clist.append($focus-order, nav)
Dlist.nth($focus-order, 2)
Attempts:
2 left
💡 Hint
Think about how to add an item at a specific position in a list.

Practice

(1/5)
1.

What is the main purpose of the sass:list module in Sass?

easy
A. To provide functions for managing lists like adding or removing items
B. To create color palettes automatically
C. To handle font styles and sizes
D. To compile Sass files into CSS

Solution

  1. Step 1: Understand the sass:list module role

    The sass:list module offers functions to work with lists, such as adding, removing, or finding items.
  2. Step 2: Compare options with module purpose

    Options A, B, and D describe unrelated tasks like colors, fonts, or compilation, which are not the sass:list module's job.
  3. Final Answer:

    To provide functions for managing lists like adding or removing items -> Option A
  4. Quick Check:

    sass:list = list management [OK]
Hint: sass:list is all about list operations, not colors or fonts [OK]
Common Mistakes:
  • Confusing sass:list with color or font modules
  • Thinking sass:list compiles Sass files
  • Assuming sass:list handles CSS properties directly
2.

Which of the following is the correct way to import the sass:list module in your Sass file?

easy
A. @forward "sass:list";
B. @import "sass:list";
C. @include "sass:list";
D. @use "sass:list";

Solution

  1. Step 1: Recall Sass module import syntax

    Modern Sass uses @use to import modules, not @import which is deprecated.
  2. Step 2: Match options with correct syntax

    @use "sass:list"; uses @use "sass:list"; which is the correct way to import the list module.
  3. Final Answer:

    @use "sass:list"; -> Option D
  4. Quick Check:

    Use @use for modules [OK]
Hint: Always use @use for Sass modules, not @import [OK]
Common Mistakes:
  • Using @import instead of @use
  • Confusing @include with module import
  • Using @forward incorrectly for importing
3.

Given the Sass code below, what will be the output of list.length($colors)?

@use "sass:list";
$colors: red, green, blue;

.result {
  length: list.length($colors);
}
medium
A. length: 1;
B. length: 0;
C. length: 3;
D. length: 4;

Solution

  1. Step 1: Understand the list variable

    The variable $colors contains three items: red, green, and blue.
  2. Step 2: Apply list.length function

    The list.length() function returns the number of items in the list, which is 3 here.
  3. Final Answer:

    length: 3; -> Option C
  4. Quick Check:

    3 items in list = 3 [OK]
Hint: Count items separated by commas for list length [OK]
Common Mistakes:
  • Counting commas instead of items
  • Confusing list length with string length
  • Forgetting to import sass:list module
4.

Identify the error in the following Sass code using sass:list module:

@use "sass:list";
$items: 1 2 3;
$new-items: list.push($items, 4);

.result {
  content: $new-items;
}
medium
A. Using list.push instead of list.append
B. Missing commas between list items in $items
C. Incorrect module import syntax
D. Cannot append numbers to lists

Solution

  1. Step 1: Check list syntax in $items

    The list $items is written as 1 2 3 without commas, which is valid space-separated list.
  2. Step 2: Understand list.append behavior

    The sass:list module has list.append() to add items, but no list.push().
  3. Step 3: Identify the error

    The code uses non-existent list.push(), causing a compilation error. Change to list.append().
  4. Final Answer:

    Using list.push instead of list.append -> Option A
  5. Quick Check:

    sass:list.append exists, list.push does not [OK]
Hint: sass:list uses list.append, not list.push [OK]
Common Mistakes:
  • Confusing list.append with list.push (no list.push in sass:list)
  • Assuming space-separated lists are always safe
  • Ignoring module import correctness
5.

You want to combine two lists $list1: 1, 2, 3; and $list2: 4, 5; into one list using sass:list functions. Which code snippet correctly joins these lists?

@use "sass:list";

// Options:
// A
$combined: list.length($list1) + list.length($list2);

// B
$combined: list.append($list1, $list2);

// C
$combined: list.insert($list1, $list2, 1);

// D
$combined: list.join($list1, $list2, comma);
hard
A. $combined: list.length($list1) + list.length($list2);
B. $combined: list.join($list1, $list2, comma);
C. $combined: list.insert($list1, $list2, 1);
D. $combined: list.append($list1, $list2);

Solution

  1. Step 1: Understand list.join function

    The list.join() function combines two lists into one, with a separator (comma or space).
  2. Step 2: Analyze each option

    $combined: list.join($list1, $list2, comma); correctly uses list.join($list1, $list2, comma) to join lists with commas.
    $combined: list.append($list1, $list2); appends the entire second list as one item, not merging.
    $combined: list.insert($list1, $list2, 1); inserts the whole second list at position 1, nesting it.
    $combined: list.length($list1) + list.length($list2); adds lengths, not lists.
  3. Final Answer:

    $combined: list.join($list1, $list2, comma); -> Option B
  4. Quick Check:

    Use list.join to merge lists [OK]
Hint: Use list.join to merge two lists cleanly [OK]
Common Mistakes:
  • Using list.append to merge lists (adds as one item)
  • Using list.insert to add whole list inside another
  • Adding lengths instead of joining lists
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard