DEV Community

Drew Hoover
Drew Hoover

Posted on

Least Confusing Way To Check Lots of Conditions

What is most clear and easy to read:

const myCondition = (a && b) || (a && c) || d || e;

-- or --

const myCondition = [a && b, a && c, d, e].some((cond) => !!cond);

Comment and tell me what you think! I tend to find lots of boolean logic difficult to read just because there are so many gotchas and I'm looking for better ways to write this kind of code.

Top comments (0)