DEV Community

Discussion on: The JavaScript Switch Statement Explained with Examples

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

It's important to note that the case 'values' are expressions too. This is perfectly valid (and useful sometimes):

switch (true) {
   case a==b:
      // do something
   break;
   case a==7:
   case a>b:
      // do something else
      break;
   default:
      // do another thing
}
Enter fullscreen mode Exit fullscreen mode