Why must you update the loop variable inside a @while loop in Sass?
If you don’t update the loop variable, the condition stays true forever, causing an infinite loop. You must increase or change the variable to eventually stop the loop.
Click to reveal answer
beginner
What happens if the @while loop condition is false at the start?
The loop block does not run at all. Sass skips the styles inside the @while block because the condition is not met.
Click to reveal answer
beginner
Give a real-life example where @while loop in Sass can be useful.
When you want to create multiple classes with incremental styles, like buttons with increasing padding or grid columns with different widths, @while helps write less code and keep it consistent.
Click to reveal answer
What must you do inside a @while loop to avoid an infinite loop?
AUpdate the loop variable so the condition eventually becomes false
BUse <code>@break</code> outside the loop
CWrite the loop without any condition
DUse <code>@if</code> inside the loop
✗ Incorrect
You must update the loop variable inside the @while loop so the condition will eventually be false and stop the loop.