What does the type-of() function in the sass:meta module do?
It tells you the kind of value you have, like if it's a number, string, color, list, map, or boolean.
Click to reveal answer
beginner
How does the inspect() function help when working with Sass values?
It turns any Sass value into a readable string so you can see exactly what's inside, which helps when debugging.
Click to reveal answer
beginner
Example: What will type-of(#ff0000) return?
It returns "color" because #ff0000 is a color value.
Click to reveal answer
intermediate
Why is using inspect() better than just printing a value directly in Sass?
Because inspect() shows the full structure and details of complex values like lists or maps, making it easier to understand what you have.
Click to reveal answer
intermediate
What kind of Sass values can type-of() recognize?
It can recognize: string, number, color, boolean, list, map, null, and function.
Click to reveal answer
What does type-of(42) return in Sass?
A"color"
B"string"
C"number"
D"boolean"
✗ Incorrect
42 is a number, so type-of() returns "number".
Which function converts a Sass value into a readable string?
Atype-of()
Binspect()
Clength()
Dmap-get()
✗ Incorrect
inspect() turns any Sass value into a string you can read.
What will type-of((1, 2, 3)) return?
A"map"
B"number"
C"string"
D"list"
✗ Incorrect
A comma-separated group like (1, 2, 3) is a list in Sass.
Why use inspect() when debugging Sass code?
ATo see the detailed structure of values
BTo remove values
CTo add colors to output
DTo change the value type
✗ Incorrect
inspect() helps you see exactly what a value contains.
Which of these is NOT a type recognized by type-of()?
Aarray
Bfunction
Cboolean
Dnull
✗ Incorrect
Sass does not have an 'array' type; it uses lists instead.
Explain how the type-of() function helps you understand Sass values.
Think about how knowing the type helps you decide what to do with a value.
You got /3 concepts.
Describe a situation where using inspect() would make debugging Sass easier.
Imagine you want to see what's inside a variable that holds many values.
You got /3 concepts.
Practice
(1/5)
1. What does the Sass function type-of() do?
easy
A. It changes the type of a Sass value.
B. It prints the value to the console.
C. It converts Sass code to CSS.
D. It tells you the kind of value you have in Sass.
Solution
Step 1: Understand the purpose of type-of()
This function returns the type of a given Sass value, like string, number, color, etc.
Step 2: Compare options with the function's behavior
Only It tells you the kind of value you have in Sass. correctly describes that it tells the kind of value you have.
Final Answer:
It tells you the kind of value you have in Sass. -> Option D
Quick Check:
type-of() = tells value type [OK]
Hint: Remember: type-of() reveals the value's kind [OK]
Common Mistakes:
Thinking type-of() changes the value type
Confusing type-of() with output functions
Assuming it converts Sass to CSS
2. Which of the following is the correct syntax to use inspect() on a Sass variable $color?
easy
A. inspect($color)
B. inspect $color;
C. inspect($color);
D. inspect $color()
Solution
Step 1: Recall correct function call syntax in Sass
Functions require parentheses around arguments and no semicolon inside the parentheses.
Step 2: Check each option's syntax
inspect($color) uses inspect($color) which is correct. inspect($color); has an extra semicolon inside parentheses, B misses parentheses, D has incorrect parentheses placement.
Final Answer:
inspect($color) -> Option A
Quick Check:
Function calls need parentheses [OK]
Hint: Use parentheses for Sass function calls [OK]
Common Mistakes:
Omitting parentheses for function calls
Adding semicolon inside function parentheses
Misplacing parentheses after variable
3. Given the Sass code:
$value: 10px;
$result: type-of($value);
What is the value of $result?
medium
A. "string"
B. "number"
C. "length"
D. "px"
Solution
Step 1: Identify the type of $value
The value 10px is a number with a unit in Sass, so its type is "number".
Step 2: Understand what type-of() returns
It returns the type as a string, so $result will be "number".
Final Answer:
"number" -> Option B
Quick Check:
10px is a number type [OK]
Hint: Units don't change type; 10px is still a number [OK]
Common Mistakes:
Thinking units create a new type like 'length'
Confusing string with number
Assuming type-of returns the unit
4. What is wrong with this Sass code?
$val: #ff0000;
$result: inspect $val;
medium
A. Missing parentheses for the inspect function call.
B. The variable $val is not defined.
C. inspect cannot be used with color values.
D. inspect requires a semicolon after the variable.
Solution
Step 1: Check function call syntax
In Sass, functions must be called with parentheses around arguments.
Step 2: Identify the error in the code
The code uses inspect $val; without parentheses, which is invalid syntax.
Final Answer:
Missing parentheses for the inspect function call. -> Option A
Quick Check:
Functions need parentheses [OK]
Hint: Always use parentheses when calling Sass functions [OK]
Common Mistakes:
Calling functions without parentheses
Assuming inspect can't handle colors
Thinking semicolon is needed inside function call
5. You want to create a Sass mixin that prints the type and value of any input variable for debugging. Which code correctly uses type-of() and inspect() together?
hard
A. @mixin debug($var) { content: "Type: $var.type, Value: $var.inspect"; }
B. @mixin debug($var) { content: "Type: type-of($var), Value: inspect($var)"; }
C. @mixin debug($var) { content: "Type: #{type-of($var)}, Value: #{inspect($var)}"; }
D. @mixin debug($var) { content: "Type: #{inspect(type-of($var))}, Value: #{type-of(inspect($var))}"; }
Solution
Step 1: Understand string interpolation in Sass
Use #{} to insert function results inside strings.