Did you know that there is two other ways to do an “if” statement that’s not a switch statement? https://1921681254.mx/
Instead of if (2 === 2) {…do something}; else {…do something};
(2 === 2) && {…do something};
(2 ===2) ? {…do something} : {…do something };
So you can use an && operator to do an equivalent if statement for one outcome. Then you can do a conditional ?: operator if you want.
I’ve known about the conditional operator but I didn’t know you can do something similar with the && operator.
The && operator returns the value on the right if the value on the left is true. It will return the value on the left if the left value is false. The value on the right should always be true in this type of scenario.