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 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);
Attempts:
2 left
💡 Hint
The
str-insert function inserts a string at a specific index.✗ Incorrect
The
str-insert function inserts the second string argument into the first string at the given index. Index 6 is right after 'Hello', so the dash is inserted there.🧠 Conceptual
intermediate1: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?
Attempts:
2 left
💡 Hint
The function name starts with 'str-' and relates to length.
✗ Incorrect
The correct Sass function to get the number of characters in a string is
str-length().❓ selector
advanced2:00remaining
What error occurs when using str-slice with invalid indexes?
Given the Sass code
str-slice("Sass", 5, 10), what happens?Attempts:
2 left
💡 Hint
If the start index is beyond the string length, what does str-slice return?
✗ Incorrect
If the start index is greater than the string length,
str-slice returns an empty string instead of an error.❓ rendering
advanced2: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; }
Attempts:
2 left
💡 Hint
The
unquote function removes quotes so the color is valid CSS.✗ Incorrect
The variable $color becomes the color code #1a2b3c without quotes, so the background color is a dark blue-gray shade.
❓ accessibility
expert3: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; }
Attempts:
2 left
💡 Hint
Sass interpolation helps combine strings inside content property correctly.
✗ Incorrect
Using interpolation with #{...} correctly inserts the aria-label string as content, making it accessible for screen readers.