forked from JMoss89/javascript-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbooleans.js
More file actions
113 lines (97 loc) · 1.48 KB
/
booleans.js
File metadata and controls
113 lines (97 loc) · 1.48 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
const negate = (a) => !a;
const both = (a, b) => {
if (!a || !b) {
return false;
}
return true;
}
const either = (a, b) => {
if (a || b) {
return true;
}
return false;
}
const none = (a, b) => {
if (a || b) {
return false;
}
return true;
}
const one = (a, b) => {
if ((a && !b) || (b && !a)) {
return true;
}
return false;
}
const truthiness = (a) => {
if(a){
return true;
}
return false;
}
const isEqual = (a, b) => {
if (a === b){
return true;
}
return false;
}
const isGreaterThan = (a, b) => {
if (a > b){
return true;
}
return false;
}
const isLessThanOrEqualTo = (a, b) => {
if (a <= b){
return true;
}
return false;
}
const isOdd = (a) => {
if (a % 2 === 1){
return true;
}
return false;
}
const isEven = (a) => {
if (a % 2 === 0){
return true;
}
return false;
}
const isSquare = (a) => {
if (Math.sqrt(a) % 1 === 0){
return true;
}
return false;
}
const startsWith = (char, string) => {
if (string.startsWith(char) === true){
return true;
}
return false;
}
const containsVowels = (string) => /[aeiou]/gi.test(string);
const isLowerCase = (string) => {
if (string === string.toLowerCase()){
return true;
}
return false;
}
module.exports = {
negate,
both,
either,
none,
one,
truthiness,
isEqual,
isGreaterThan,
isLessThanOrEqualTo,
isOdd,
isEven,
isSquare,
startsWith,
containsVowels,
isLowerCase
};