0
0
SASSmarkup~20 mins

String types and concatenation 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?
Consider the following Sass code snippet. What will be the value of $result after compilation?
SASS
$part1: "Hello";
$part2: 'World';
$result: $part1 + ' ' + $part2;
AHello World
B"HelloWorld"
C"Hello World"
DError: Invalid operation
Attempts:
2 left
💡 Hint
Remember how Sass handles string concatenation with the plus (+) operator.
🧠 Conceptual
intermediate
2:00remaining
Which option correctly concatenates two strings in Sass?
You want to join two strings stored in variables $a and $b with a space between them. Which option will work correctly?
SASS
$a: "Good";
$b: "Morning";
A$result: "#{$a} #{$b}";
B$result: $a + ' ' + $b;
C$result: $a $b;
D$result: concat($a, ' ', $b);
Attempts:
2 left
💡 Hint
Think about how Sass uses interpolation to combine strings.
rendering
advanced
2:00remaining
What CSS output does this Sass produce?
Given the Sass code below, what will be the rendered CSS for the .greeting class?
SASS
.greeting {
  $hello: "Hello";
  $name: 'Alice';
  content: "#{$hello}, #{$name}!";
}
A
.greeting {
  content: "Hello, Alice!";
}
B
.greeting {
  content: Hello, Alice!;
}
CSyntax error during compilation
D
.greeting {
  content: '#{$hello}, #{$name}!';
}
Attempts:
2 left
💡 Hint
Check how interpolation works inside property values.
selector
advanced
2:00remaining
Which Sass selector uses string interpolation correctly?
You want to create a class selector with a dynamic part stored in $name. Which option correctly creates a selector like .btn-primary if $name: 'primary'?
SASS
$name: 'primary';
A.btn-'#{$name}' { color: blue; }
B.btn-$name { color: blue; }
C.btn-#{$name} { color: blue; }
D.btn-{$name} { color: blue; }
Attempts:
2 left
💡 Hint
Remember how to use interpolation in selectors.
accessibility
expert
3:00remaining
How to concatenate strings for ARIA labels in Sass?
You want to create an ARIA label combining a button type and state stored in variables $type and $state. Which Sass code produces aria-label="Submit button active" in the compiled CSS?
SASS
$type: 'Submit';
$state: 'active';
A
button {
  aria-label: $type + ' button ' + $state;
}
B
button {
  aria-label: "#{$type} button #{$state}";
}
C
button {
  aria-label: '#{$type} button #{$state}';
}
D
button {
  aria-label: concat($type, ' button ', $state);
}
Attempts:
2 left
💡 Hint
Use interpolation inside double quotes for attribute values.