I have the following code snippet:
const value1 = isSomething ? 'a' : isSomethingElse ? 'b' : 'c'; const value2 = isSomething ? 1 : isSomethingElse ? 2 : 3; Those two variables depend on the same behavior of other variables ( isSomething and isSomethingElse )
Is there a way to write this code in one line?
You can use destructuring arrays and assignment, but it won't be faster:
const [value1, value2] = isSomething ? ['a', 1] : isSomethingElse ? ['b', 2] : ['c', 3];