JS LOGICChapter 2 · JS Conditionals & Logic
Switch Statements
A switch compares one value against several case labels using === and runs the matching block. End each case with break, or execution falls through into the next case. A default case runs when nothing matches. Stacking two cases with no code between them lets both share one block.
Worked example
How it reads
- Each
caseis compared with===againstphase breakstops the switch after the matching blockdefaultcatches every value no case matched
Common mistakes
- Forgetting
breakmakes the code fall through and run the next case too.

Cloud tip: A switch reads well when you compare one value against many fixed options. For ranges like
score > 90, use if and else if.

