xor.md Added

This commit is contained in:
Bhaskar Maity
2020-10-05 23:49:21 +05:30
parent 9e6882f04e
commit 34e5528132

20
snippets/xor.md Normal file
View File

@ -0,0 +1,20 @@
---
title: xor
tags: math,logic,beginner
---
Returns `true` if only one of the arguments is `true`, `false` otherwise.
- Using basic or (`||`), and (`&&`), and not (`!`) operators Logical xor.
- You can use the Bitwise xor (`^`) operator also on the two given values.
```js
const xor = (a, b) => ( ( a || b ) && !( a && b ) );
```
```js
xor(true, true); // false
xor(true, false); // true
xor(false, true); // true
xor(false, false); // false
```