A. Cannot multiply number by unit directly in map-merge key-value
B. map-merge syntax is incorrect; keys must be strings
C. The function does not initialize $scale as a map
D. Using $i: $i * 0.25rem inside map-merge is invalid syntax
Solution
Step 1: Analyze map-merge usage
map-merge expects a map and a map as arguments. The second argument must be a map with key-value pairs.
Step 2: Check key-value pair syntax
$i: $i * 0.25rem is invalid inside map-merge because $i: is not a valid map literal key syntax. It should be ($i: $i * 0.25rem) wrapped in parentheses.
Final Answer:
Using $i: $i * 0.25rem inside map-merge is invalid syntax -> Option D
Quick Check:
map-merge needs proper map syntax [OK]
Hint: Wrap key-value pair in parentheses for map-merge [OK]
Common Mistakes:
Forgetting parentheses around key-value pair in map-merge
Trying to multiply unitless number by unit incorrectly
Not initializing $scale as empty map ()
5. You want to create a spacing scale in Sass that doubles each step starting from 0.25rem for 5 steps (0.25rem, 0.5rem, 1rem, 2rem, 4rem). Which function correctly generates this scale as a map with keys 1 to 5?
hard
A. @function generate-scale($steps) {
$scale: ();
$value: 0.25rem;
@for $i from 1 through $steps {
$scale: map-merge($scale, ($i: $value));
$value: $value * 2;
}
@return $scale;
}
B. @function generate-scale($steps) {
$scale: ();
@for $i from 1 through $steps {
$scale: map-merge($scale, ($i: 0.25rem * $i));
}
@return $scale;
}