Challenge - 5 Problems
Sass String 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 string.length?
Consider the following Sass code snippet:
What will be the rendered CSS content value?
@use "sass:string";
$my-string: "Hello, Sass!";
$length: string.length($my-string);
.result {
content: $length;
}What will be the rendered CSS content value?
SASS
@use "sass:string"; $my-string: "Hello, Sass!"; $length: string.length($my-string); .result { content: $length; }
Attempts:
2 left
💡 Hint
Count all characters including spaces and punctuation.
✗ Incorrect
The string "Hello, Sass!" has 13 characters including the comma, space, and exclamation mark.
🧠 Conceptual
intermediate2:00remaining
Which option correctly extracts the substring "Sass" using string.slice?
Given the string $text: "Welcome to Sass!" in Sass, which option correctly extracts the substring "Sass" using the string.slice function?
SASS
@use "sass:string"; $text: "Welcome to Sass!"; $sub: string.slice($text, ?, ?); .result { content: $sub; }
Attempts:
2 left
💡 Hint
Remember that string.slice uses 1-based indexing and includes both start and end positions.
✗ Incorrect
The substring "Sass" starts at character 12 and ends at character 15, so slicing from 12 to 15 extracts "Sass".
❓ selector
advanced2:00remaining
What CSS is generated by this Sass code using string.insert?
Analyze this Sass code:
What is the content value in the generated CSS?
@use "sass:string";
$base: "color";
$inserted: string.insert($base, "ful", 6);
.result {
content: $inserted;
}What is the content value in the generated CSS?
SASS
@use "sass:string"; $base: "color"; $inserted: string.insert($base, "ful", 6); .result { content: $inserted; }
Attempts:
2 left
💡 Hint
string.insert inserts the new string before the character at the given index.
✗ Incorrect
Inserting "ful" at position 6 (after 'r') in "color" results in "colorful".
❓ layout
advanced2:00remaining
How does string.repeat affect layout when used in content?
Given this Sass code:
What will the user see in the browser?
@use "sass:string";
$pattern: string.repeat("-", 5);
.divider::before {
content: $pattern;
display: block;
text-align: center;
}What will the user see in the browser?
SASS
@use "sass:string"; $pattern: string.repeat("-", 5); .divider::before { content: $pattern; display: block; text-align: center; }
Attempts:
2 left
💡 Hint
string.repeat repeats the string horizontally the given number of times.
✗ Incorrect
string.repeat("-", 5) produces "-----" which is shown centered in the block.
❓ accessibility
expert3:00remaining
Which option best ensures accessible dynamic content using string.replace in Sass?
You want to replace all underscores (_) with spaces in a CSS content property for better screen reader clarity. Which Sass code snippet using string.replace achieves this correctly and accessibly?
SASS
@use "sass:string"; $text: "user_name_profile"; $clean-text: string.replace($text, "_", " ", ?); .accessible { content: $clean-text; }
Attempts:
2 left
💡 Hint
To replace all occurrences, use the correct fourth argument.
✗ Incorrect
Using "all" as the fourth argument replaces every underscore with a space, improving screen reader text clarity.