switch

switch executes code when the condition matches a case.

Break ends the code.

Default executes when no case is a match.

Syntax

switch (condition) {
  case 1:
    code
    break;
  case 2:
    code
    break;
  ...
  default:
    code
}

Example

External

Mozilla Developer Network