Re:Using the switch(true) pattern in JavaScript
by wvenable on Monday April 12, 2021 @06:03PM
(#26785743)
The tests are rarely that simple or regular.
[ Parent
| on HN ]
Re:Using the switch(true) pattern in JavaScript
by jhgb on Monday April 12, 2021 @06:25PM
(#26785943)
Isn't that exactly the reason to put them somewhere else?
Re:Using the switch(true) pattern in JavaScript
by wvenable on Monday April 12, 2021 @06:30PM
(#26785995)
No, I just mean the actual tests might be something like:
if (user == null) return false;
if (IsCompleted(user)) return true;
if (action == null) return false;
if (value < 0 || value > 100) return false;
You're not usually just passing a single value to a bunch of "test" functions.