A switch statement evaluates an expression and executes code based on matching cases. It’s useful when testing a single variable against multiple values.

Syntax:

JavaScript
switch (expression) {
  case value1:
    // Code to execute if expression === value1
    break;
  case value2:
    // Code to execute if expression === value2
    break;
  default:
    // Code to execute if no cases match
}

Example:

JavaScript
let day = "Monday";

switch (day) {
  case "Monday":
    console.log("Start of the week!");
    break;
  case "Friday":
    console.log("Almost weekend!");
    break;
  default:
    console.log("It's just another day.");
}