0
0
SASSmarkup~20 mins

Built-in string functions in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass String 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 string functions?
Consider the following Sass code snippet. What will be the value of $result after compilation?
SASS
$text: "Hello World";
$result: str-insert($text, "-", 6);
A"Hello- World"
B"Hello World-"
C"-Hello World"
D"Hello World"
Attempts:
2 left
💡 Hint
The str-insert function inserts a string at a specific index.
🧠 Conceptual
intermediate
1:30remaining
Which Sass function returns the length of a string?
You want to find out how many characters are in a string variable in Sass. Which function should you use?
Astr-length()
Blength()
Cstring-length()
Dcount()
Attempts:
2 left
💡 Hint
The function name starts with 'str-' and relates to length.
selector
advanced
2:00remaining
What error occurs when using str-slice with invalid indexes?
Given the Sass code str-slice("Sass", 5, 10), what happens?
A"s"
B"" (empty string)
CError: Invalid index
D"Sass"
Attempts:
2 left
💡 Hint
If the start index is beyond the string length, what does str-slice return?
rendering
advanced
2:30remaining
What is the output color of this Sass code using string functions?
This Sass code uses string functions to create a color variable. What color will be rendered in the browser?
SASS
$hex: "#1a2b3c";
$color: unquote($hex);
body { background-color: $color; }
ABackground color is #1a2b3c (bright red)
BCompilation error due to unquote usage
CBackground color is transparent
DBackground color is #1a2b3c (a dark blue-gray)
Attempts:
2 left
💡 Hint
The unquote function removes quotes so the color is valid CSS.
accessibility
expert
3:00remaining
How can you use Sass string functions to improve accessibility in CSS content?
You want to add dynamic content with a screen reader label using Sass string functions. Which approach correctly combines strings for accessibility?
SASS
$label: "Close button";
$aria: "aria-label='" + $label + "'";
.button::after { content: $aria; }
AUse unquote: content: unquote("aria-label='" + $label + "'");
BUse str-insert to add quotes: content: str-insert($aria, '"', 1);
CUse interpolation: content: "#{"aria-label='" + $label + "'"}";
DUse str-length to set content length: content: str-length($aria);
Attempts:
2 left
💡 Hint
Sass interpolation helps combine strings inside content property correctly.