News for hackers. Stuff that matters.
Re:Using the switch(true) pattern in JavaScript by alerighi on Monday April 12, 2021 @07:10PM (#26786293)
That code is ugly anyway, something I would have wrote in middle school... why not:

    function check(x) {
        return test1(x) && test2(x) && test3(x) && test4(x);
    }
Or, since I assume is JavaScript, just:

    const check = x => test1(x) && test2(x) && test3(x) && test4(x);
Re:Using the switch(true) pattern in JavaScript by brundolf on Tuesday April 13, 2021 @12:29PM (#26794862)
Nobody would actually write this, it's just a demonstration of the pattern at hand for the sake of discussion