News for hackers. Stuff that matters.
Re:Using the switch(true) pattern in JavaScript by brundolf on Monday April 12, 2021 @03:44PM (#26784191)
Worth noting that elses don't require curly braces, which are where most of the visual noise is coming from in your example:

  function check(x) {
    if (!test1 (x))      return false; 
    else if (!test2 (x)) return false;
    else if (!test3 (x)) return false;
    else if (!test4 (x)) return false;
    else                 return true;
  }
I think this is more clear than either of the above
Re:Using the switch(true) pattern in JavaScript by tpoacher on Monday April 12, 2021 @03:49PM (#26784249)
> Worth noting that elses don't require curly braces

True. I still think the first is clearer though. Either all tests pass, or they don't.

Re:Using the switch(true) pattern in JavaScript by tpoacher on Monday April 12, 2021 @03:50PM (#26784257)
(also I'd be very skeptical of such an if..else ladder. Prime target for bugs.)