switch Statement
noun
say it: “SWICH STAYT-ment” /swɪtʃ ˈsteɪtmənt/
A statement that compares one value against a list of cases and runs the code for the case that matches, with default for no match.
What does switch Statement do in JavaScript?
switch Statement — A statement that selects a code path by matching one value against cases.
switch (size) {
case "M":
label = "Medium";
break;
default:
label = "Other";
}
In a sentence
- “My switch statement turns the size "S", "M" or "L" into a price.”
Level: Novice · More JavaScript terms at this level
Updated