EDIT: So, it seems like there's not really a "better" way of doing this, but a lot of folks are pointing out that a hashmap approach might be more readable/composable.
Given the following function:
const isOpposites = (a, b) => {
return (
(a === "SOUTH" && b === "NORTH") ||
(b === "SOUTH" && a === "NORTH") ||
(a === "EAST" && b === "WEST") ||
(a === "WEST" && b === "EAST")
)
};
Is there a simpler way (one-liner, maybe) of checking whether a and b are opposites?
*There are only four possible values for a and b, they are: "NORTH", "SOUTH","EAST" and "WEST"