← JavaScript

switch Statement

Compares a value against multiple case labels and runs the code block for the matching case.

Understanding switch Statement in JavaScript

What it does: break exits the switch once a matching case has run. default is the fallback case in a switch statement. switch checks the value against each case in turn. A case label is written as case value:. JavaScript is case-sensitive, so 'switch' must be lowercase. Without break, execution continues into the next case block. The value being checked goes inside switch ( ). Case labels always use a colon, never a semicolon.

Common mistakes: 'switch' is misspelled as 'swich'. Missing the opening parenthesis before day.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 11–25) and word search (Modules 1–29).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Does switch compare a value against multiple case labels?
YesNo
Matches
case 1
↓
Wrong - case labels need a colon after the value
Applying
Meanings
Term
switch
Meaning
Compares a value against multiple case labels and runs the code block for the matching case.
Practice
let day = 3;
Testing
Gaps
(day) {
Check Answer
Spots
1swich (day) {
2case 1:

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Jellyfish' badge — Flow Controller, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Does switch compare a value against multiple case labels?
A. Yes ✓
B. No
switch checks the value against each case in turn.
2. Does each case label end with a colon?
A. Yes ✓
B. No
A case label is written as case value:.
3. Is 'Switch' with a capital S valid JavaScript syntax?
A. No ✓
B. Yes
JavaScript is case-sensitive, so 'switch' must be lowercase.
4. Does break stop the code from running into the next case?
A. No
B. Yes ✓
Without break, execution continues into the next case block.
5. Does switch put the value to compare inside parentheses?
A. No
B. Yes ✓
The value being checked goes inside switch ( ).

Match the Pairs

switch (day) { → Compares day against each case label
case 3: → Matches when the switch value equals 3
Stops the code from falling into the next case → break;
Runs when no case value matches → default:
case 1 → Wrong - case labels need a colon after the value
Break; → Wrong - 'break' must be lowercase

Key Term

switch
Compares a value against multiple case labels and runs the code block for the matching case.

Fill in the Blanks

1. switch (day) {
Hint: Type the keyword that starts a switch statement.
2. case 1: console.log("Monday"); break;
Hint: Type the keyword that stops the code falling into the next case.
3. case 2: console.log("Two"); break;
Hint: Type the value this case matches.
4. default: console.log("Fallback");
Hint: Type the keyword used as the fallback case.
5. case 5: console.log("Five"); break;
Hint: Type the keyword that stops the code falling into the next case.

Spot the Error

Question 1
A swich (day) {
B case 1:
C break;
Line A — 'switch' is misspelled as 'swich'.
Question 2
A switch day) {
B case 2:
C break;
Line A — Missing the opening parenthesis before day.
Question 3
A switch (day) {
B case 1
C break;
Line B — Case labels need a colon after the value: case 1:.
Question 4
A switch (num) {
B case 5;
C break;
Line B — Case labels use a colon :, not a semicolon ;.
Question 5
A switch (x) {
B case 1:
C Break;
Line C — 'break' must be lowercase - a capital B causes an error.

Student with a class code? Join your class →