Recall & Review
beginner
What is a global variable in Sass?
A global variable in Sass is a variable declared outside any selector or function. It can be accessed anywhere in the stylesheet unless overridden by a local variable with the same name.
Click to reveal answer
beginner
What is a local variable in Sass?
A local variable in Sass is a variable declared inside a selector, function, or mixin. It only exists within that block and cannot be accessed outside it.
Click to reveal answer
intermediate
How do you make a local variable affect the global variable in Sass?
You use the
!global flag when assigning a variable inside a block. This updates the global variable instead of creating a new local one.Click to reveal answer
intermediate
What happens if you declare a variable with the same name both globally and locally in Sass?
The local variable overrides the global one inside its block. Outside the block, the global variable value is used.
Click to reveal answer
beginner
Why is understanding variable scope important in Sass?
It helps avoid unexpected styles by controlling where variables can be used or changed. It keeps stylesheets organized and easier to maintain.
Click to reveal answer
Where is a Sass variable declared outside any selector accessible?
✗ Incorrect
A variable declared outside any selector is global and accessible anywhere unless overridden locally.
What does the
!global flag do in Sass?✗ Incorrect
The
!global flag updates the global variable from inside a local block.If a variable is declared both globally and locally with the same name, which one is used inside the local block?
✗ Incorrect
The local variable overrides the global one inside its block.
Can a local variable in Sass be accessed outside its block?
✗ Incorrect
Local variables exist only inside their block and cannot be accessed outside.
Why should you be careful with variable scope in Sass?
✗ Incorrect
Understanding scope helps avoid unexpected style changes and keeps code organized.
Explain the difference between global and local variables in Sass and how the
!global flag works.Think about where variables can be used and changed.
You got /4 concepts.
Describe a real-life example where variable scope in Sass helps keep your styles organized.
Imagine managing colors or sizes in a big project.
You got /4 concepts.