1

I have this switch statement where a, b, c and d can be true or false, but only one of them is going to be true, and when one of them is true it returns X which is a variable. How can I replace this switch statement with an object literal?

switch (true) {
        a: return x
        b: return x
        c: return x
        d: return x
      }
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • I don't think it's possible to do this. More important, why would you want to? What are you trying to accomplish that isn't working with your current code? – kmoser Mar 05 '22 at 03:40

0 Answers0