-
Notifications
You must be signed in to change notification settings - Fork 328
Expand file tree
/
Copy pathbooleans.js
More file actions
51 lines (36 loc) · 906 Bytes
/
booleans.js
File metadata and controls
51 lines (36 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const negate = a => !a;
const both = (a, b) => a && b;
const either = (a, b) => a || b;
const none = (a, b) => !a && !b;
const one = (a, b) => {
if (a && !b) return true;
if (!a && b) return true;
return false;
};
const truthiness = a => Boolean(a);
const isEqual = (a, b) => a === b;
const isGreaterThan = (a, b) => a > b;
const isLessThanOrEqualTo = (a, b) => a <= b;
const isOdd = a => !(a % 2 === 0);
const isEven = a => a % 2 === 0;
const isSquare = a => Math.sqrt(a) % 1 === 0;
const startsWith = (char, string) => string.startsWith(char);
const containsVowels = string => Boolean(string.match(/[aeiou]/gi));
const isLowerCase = string => string === string.toLowerCase();
module.exports = {
negate,
both,
either,
none,
one,
truthiness,
isEqual,
isGreaterThan,
isLessThanOrEqualTo,
isOdd,
isEven,
isSquare,
startsWith,
containsVowels,
isLowerCase
};