2 ms·
Rename a and b to reasonable names: a -> isAdmin b -> isActive const isDeletableUser = !isAdmin && isActive; return isDeletableUser; (Better would
by ballenf 8y ago
Rename a and b to reasonable names:
a -> isAdmin
b -> isActive
const isDeletableUser = !isAdmin && isActive;
return isDeletableUser;
(Better would be naming the function "isDeletableUser" instead of the intermediate const, but was keeping with the original.)
Point is for me that booleans with readable names shows how eliminating ifs becomes not only doable but arguably preferable.