SASS Variables and Data Types 2 — Questions and Answers
Question 1: Which Sass function retrieves a value from a map?
- map.get() (Correct answer)
- map-fetch()
- get-value()
- map.find()
Correct answer: map.get()
The `map.get($map, $key)` function returns the value associated with a given key in a Sass map.
Question 2: What is the Sass boolean data type?
- true or false (Correct answer)
- yes or no
- 1 or 0
- on or off
Correct answer: true or false
Sass booleans are the literal values `true` and `false`.
Question 3: How do you interpolate a Sass variable inside a string?
- #{$variable} (Correct answer)
- ${variable}
- @{$variable}
- {{$variable}}
Correct answer: #{$variable}
Sass string interpolation uses `#{}` syntax to embed variable values inside strings or selectors.
Question 4: What does `null` represent in Sass?
- The absence of a value (Correct answer)
- An empty string
- Zero
- An undefined variable error
Correct answer: The absence of a value
In Sass, `null` represents the absence of a value and is omitted when output to CSS.
Question 5: Which Sass function checks if a map has a specific key?
- map.has-key() (Correct answer)
- map.contains()
- map.exists()
- map.check()
Correct answer: map.has-key()
The `map.has-key($map, $key)` function returns `true` if the map contains the specified key.
Question 6: What is the scope of a variable declared inside a Sass rule block?
- Local to that block (Correct answer)
- Global across the stylesheet
- Available to sibling blocks only
- Inherited by child partials
Correct answer: Local to that block
Variables declared inside a rule block in Sass are local and not accessible outside that block.
Which Sass function retrieves a value from a map?