SCSS · Functions · Junior · Live Coding
Write a function that returns a spacing token by name.
Short Interview Answer
Accept key, look up in $spacers map, @error if missing, return value.
Detailed Explanation
Centralizes failures at compile time — better than emitting invalid CSS.
Example
@function space($k) {
@if not map.has-key($spacers, $k) { @error 'Unknown #{$k}'; }
@return map.get($spacers, $k);
}