DEV Community

Discussion on: Opinionated use of JavaScript Switch-Case

sirseanofloxley profile image
Sean Allin Newell

Wat. I am so intrigued

const someFlag = true;
const name = 'bob'; // or tom

switch (name) {
  case 'bob':
    return someFlag ? 20 : 10;
  case 'tom':
    return 5;
    return -1;

This seems clearer to me, but i can see the flexibility of your way.

rfornal profile image
bob.ts Author

I agree that yours might be clearer with a smaller example, but when using something with dozens of variables, it's clear and the flexibility is really nice.