true
.||
), and (&&
) and not (!
) operators on the two given values to create the logical xor.const xor = (a, b) => (( a || b ) && !( a && b ));
xor(true, true); // false xor(true, false); // true xor(false, true); // true xor(false, false); // false
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️