Files
30-seconds-of-code/snippets/xor.md
Isabelle Viktoria Maciohsek 8bf67754ce Make expertise a field
2022-03-01 20:21:45 +02:00

498 B

title, tags, expertise, unlisted, firstSeen, lastUpdated
title tags expertise unlisted firstSeen lastUpdated
Logical xor math,logic beginner true 2020-10-05T21:19:21+03:00 2021-01-04T13:04:15+02:00

Checks if only one of the arguments is true.

  • Use the logical or (||), 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