The Master XOR
MediumAcc. 72.4%
+40 XP 15
The Exclusive Choice
In standard logic, XOR (Exclusive OR) only returns true if exactly one of the inputs is truthy. If both are true or both are false, it returns false.
JavaScript does not have a native logical XOR operator (the ^ symbol is for bitwise operations). Your task is to build one using only ||, &&, and !.
The Assignment
Your function receives parameters a and b.
- Return
trueonly if exactly one input is truthy. - Return
falsein all other cases.
01EXAMPLE 1
Input
a = true, b = falseOutput
trueExplanation: One is true, so XOR is true.
02EXAMPLE 2
Input
a = true, b = trueOutput
falseExplanation: Both are true, so XOR is false.
Constraints
- Do not use the bitwise ^ operator.
- Return a boolean result.
LogicOperatorsMastery
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
atrue
bfalse
Expected Output
true
Click RUN to test your solution