-
Notifications
You must be signed in to change notification settings - Fork 328
Expand file tree
/
Copy pathbooleans.js
More file actions
134 lines (117 loc) · 1.88 KB
/
booleans.js
File metadata and controls
134 lines (117 loc) · 1.88 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
const negate = a => {
if (a === true) {
return false;
} else {
return true
};
};
const both = (a, b) => {
if (a === true && b === true) {
return true;
} else {
return false;
}
};
const either = (a, b) => {
if (a || b === true) {
return true;
} else {
return false;
}
};
const none = (a, b) => {
if (a === false && b === false) {
return true;
} else {
return false;
}
};
const one = (a, b) => {
if ((a === true && b === false) || (a === false && b === true)) {
return true;
} else {
return false;
}
};
const truthiness = a => {
return Boolean(a);
};
const isEqual = (a, b) => {
if (a === b) {
return true;
} else {
return false;
}
};
const isGreaterThan = (a, b) => {
if (a > b) {
return true;
} else {
return false;
}
};
const isLessThanOrEqualTo = (a, b) => {
if (a <= b) {
return true;
} else {
return false;
}
};
const isOdd = a => {
if (a % 2 === 0) {
return false;
} else {
return true;
}
};
const isEven = a => {
if (a % 2 === 0) {
return true;
} else {
return false;
}
};
const isSquare = a => {
if (Math.sqrt(a) % 1 === 0) {
return true;
} else {
return false;
}
};
const startsWith = (char, string) => {
if (string.charAt(0) === char) {
return true;
} else {
return false;
}
};
const containsVowels = string => {
let vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"];
for (i = 0; i < vowels.length; i += 1) {
let trueResult = string.includes(vowels[i]);
if (trueResult === true) {
return true;
}
}
return false;
}
const isLowerCase = string => {
return string === string.toLowerCase();
}
module.exports = {
negate,
both,
either,
none,
one,
truthiness,
isEqual,
isGreaterThan,
isLessThanOrEqualTo,
isOdd,
isEven,
isSquare,
startsWith,
containsVowels,
isLowerCase
};