forked from CommandShiftHQ/javascript-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbooleans.js
More file actions
80 lines (65 loc) · 1.02 KB
/
Copy pathbooleans.js
File metadata and controls
80 lines (65 loc) · 1.02 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function negate(a) {
return !a;
}
function both(a, b) {
return a && b;
}
function either(a, b) {
return a || b;
}
function none(a, b) {
return !a && !b;
}
function one(a, b) {
return (a && !b) || (!a && b);
}
function truthiness(a) {
if (a) {
return true;
}
return false;
}
function isEqual(a, b) {
return a === b;
}
function isGreaterThan(a, b) {
return a > b;
}
function isLessThanOrEqualTo(a, b) {
return a <= b;
}
function isOdd(a) {
return a % 2 !== 0;
}
function isEven(a) {
return a % 2 === 0;
}
function isSquare(a) {
return a >= 0 && Math.sqrt(a) % 1 === 0;
}
function startsWith(char, string) {
return string.startsWith(char);
}
function containsVowels(string) {
return !!string.match(/[aeiou]/i);
}
function isLowerCase(string) {
return string === string.toLowerCase();
}
module.exports = {
negate,
both,
either,
none,
one,
truthiness,
isEqual,
isGreaterThan,
isLessThanOrEqualTo,
isOdd,
isEven,
isSquare,
startsWith,
containsVowels,
isLowerCase
};