SASS Variables and Data Types 1 — Questions and Answers
Question 1: How do you declare a variable in Sass?
- $variable: value; (Correct answer)
- #variable: value;
- @variable: value;
- --variable: value;
Correct answer: $variable: value;
Sass variables are declared using the `$` prefix followed by the variable name and value.
Question 2: Which of the following is a valid Sass string type?
- "hello" (Correct answer)
- [hello]
- {hello}
- (hello)
Correct answer: "hello"
Sass strings can be quoted (with double or single quotes) or unquoted.
Question 3: What does the `!default` flag do when assigning a Sass variable?
- Sets the variable only if it is not already defined (Correct answer)
- Marks the variable as immutable
- Forces the variable to override existing values
- Deletes the variable after use
Correct answer: Sets the variable only if it is not already defined
The `!default` flag assigns a value to a variable only if the variable is not already defined or is null.
Question 4: Which Sass data type represents a list of values separated by spaces or commas?
- List (Correct answer)
- Map
- String
- Boolean
Correct answer: List
Sass lists are ordered sequences of values separated by spaces or commas.
Question 5: How do you define a Sass map?
- $map: (key: value, key2: value2); (Correct answer)
- $map: [key: value];
- $map: {key: value};
- $map: key => value;
Correct answer: $map: (key: value, key2: value2);
Sass maps are defined using parentheses with comma-separated key-value pairs.
Question 6: What is the result of the Sass expression `type-of(42)`?
- number (Correct answer)
- integer
- string
- value
Correct answer: number
The `type-of()` function returns `number` for numeric values in Sass.
How do you declare a variable in Sass?