SASS Operators and Expressions 2 — Questions and Answers
Question 1: What does the Sass `+` operator do with strings?
- Concatenates two strings (Correct answer)
- Adds their lengths
- Converts both to numbers
- Creates a list
Correct answer: Concatenates two strings
When used with strings, the `+` operator in Sass concatenates them into a single string.
Question 2: How do you multiply a color channel value using Sass?
- Use `color.scale()` or `color.adjust()` for channel manipulation (Correct answer)
- Use `$color * 2`
- Use `multiply($color, 2)`
- Use `@color-multiply`
Correct answer: Use `color.scale()` or `color.adjust()` for channel manipulation
Direct multiplication of color values is not standard; use `color.scale()` or `color.adjust()` to modify specific channels.
Question 3: What does `#{ }` interpolation allow you to do with operators in Sass?
- Embed any expression as a plain string without evaluating it as math (Correct answer)
- Execute shell commands
- Inject CSS calc() expressions
- Comment out an expression
Correct answer: Embed any expression as a plain string without evaluating it as math
Interpolation with `#{}` outputs the expression as a literal string, bypassing Sass math evaluation.
Question 4: Which Sass operator is used to check if a value is greater than or equal to another?
- >= (Correct answer)
- =>
- geq
- gte
Correct answer: >=
Sass uses standard comparison operators including `>=` for greater-than-or-equal comparisons.
Question 5: What does `5px * 2` evaluate to in Sass?
- 10px (Correct answer)
- 5px2
- 10
- error
Correct answer: 10px
Multiplying a unit value by a unitless number scales the value, so `5px * 2` equals `10px`.
Question 6: How do Sass operators behave with the `not` keyword?
- It negates a boolean expression, returning the opposite value (Correct answer)
- It removes a CSS property
- It inverts a number's sign
- It excludes a selector
Correct answer: It negates a boolean expression, returning the opposite value
The `not` keyword in Sass is a logical negation operator that inverts boolean expressions.
What does the Sass `+` operator do with strings?