0
0
SASSmarkup~20 mins

sass:string module - 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.length?
Consider the following Sass code snippet:
@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;
}
Acontent: 10;
Bcontent: 11;
Ccontent: 13;
Dcontent: 12;
Attempts:
2 left
💡 Hint
Count all characters including spaces and punctuation.
🧠 Conceptual
intermediate
2: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;
}
Astring.slice($text, 12, 15)
Bstring.slice($text, 11, 14)
Cstring.slice($text, 11, 15)
Dstring.slice($text, 12, 14)
Attempts:
2 left
💡 Hint
Remember that string.slice uses 1-based indexing and includes both start and end positions.
selector
advanced
2:00remaining
What CSS is generated by this Sass code using string.insert?
Analyze this Sass code:
@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;
}
Acontent: "colofulr";
Bcontent: "colorful";
Ccontent: "colorfulr";
D;"lufroloc" :tnetnoc
Attempts:
2 left
💡 Hint
string.insert inserts the new string before the character at the given index.
layout
advanced
2:00remaining
How does string.repeat affect layout when used in content?
Given this Sass code:
@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;
}
AA centered line of 5 dashes: -----
BA block with 1 dash repeated 5 times vertically
CAn error because string.repeat cannot be used in content
DA centered line of 4 dashes: ----
Attempts:
2 left
💡 Hint
string.repeat repeats the string horizontally the given number of times.
accessibility
expert
3: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;
}
Astring.replace($text, "_", " ")
Bstring.replace($text, "_", " ", 0)
Cstring.replace($text, "_", " ", "first")
Dstring.replace($text, "_", " ", "all")
Attempts:
2 left
💡 Hint
To replace all occurrences, use the correct fourth argument.