8 kyu
Exclusive "or" (xor) Logical Operator
14,015 of 46,163donaldsebleung
Description:
Exclusive "or" (xor) Logical Operator
Overview
In some scripting languages like PHP, there exists a logical operator (e.g. &&
, ||
, and
, or
, etc.) called the "Exclusive Or" (hence the name of this Kata). The exclusive or evaluates two booleans. It then returns true
if exactly one of the two expressions are true, false
otherwise. For example:
false xor false == false // since both are false
true xor false == true // exactly one of the two expressions are true
false xor true == true // exactly one of the two expressions are true
true xor true == false // Both are true. "xor" only returns true if EXACTLY one of the two expressions evaluate to true.
Task
Since we cannot define keywords in Javascript (well, at least I don't know how to do it), your task is to define a function xor(a, b)
where a
and b
are the two expressions to be evaluated. Your xor
function should have the behaviour described above, returning true
if exactly one of the two expressions evaluate to true, false
otherwise.
Fundamentals
Similar Kata:
Stats:
Created | Mar 29, 2016 |
Published | Mar 29, 2016 |
Warriors Trained | 59368 |
Total Skips | 4585 |
Total Code Submissions | 82538 |
Total Times Completed | 46163 |
JavaScript Completions | 14015 |
Ruby Completions | 1237 |
Haskell Completions | 603 |
Python Completions | 13129 |
Java Completions | 5846 |
CoffeeScript Completions | 65 |
TypeScript Completions | 1020 |
Clojure Completions | 449 |
C# Completions | 2486 |
C++ Completions | 4949 |
C Completions | 2021 |
NASM Completions | 134 |
Go Completions | 2497 |
CFML Completions | 41 |
Scala Completions | 77 |
Lua Completions | 73 |
Groovy Completions | 25 |
Dart Completions | 124 |
Total Stars | 267 |
% of votes with a positive feedback rating | 89% of 3956 |
Total "Very Satisfied" Votes | 3218 |
Total "Somewhat Satisfied" Votes | 621 |
Total "Not Satisfied" Votes | 117 |
Total Rank Assessments | 9 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |