-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathbooleans.js
158 lines (130 loc) · 2.03 KB
/
booleans.js
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
function negate(a) {
return !a;
// your code here
};
function both(a, b) {
if (a===true && b===true){
return true;
}else{
return false;
}
// your code here
}
function either(a, b) {
if (a===true || b===true){
return true
}else{
return false;
}
};
// your code here
function none(a, b) {
if (a===true || b===true){
return false
}else{
return true;
}
// your code here
};
function one(a, b) {
if(a===true && b===true){
return false;
}else if (a===true || b===true){
return true;
}else{
return false;
}
};
function truthiness(a) {
return Boolean(a);
}
// your code here
function isEqual(a, b) {
if(a===b){
return true;
}else{
return false;
}
// your code here
};
function isGreaterThan(a, b) {
if(a>b){
return true;
}else{
return false;
}
// your code here
};
function isLessThanOrEqualTo(a, b) {
if (a<=b){
return true;
}else{
return false;
}
// your code here
};
function isOdd(a) {
if(a%2!==0){
return true;
}else{
return false;
}
};
function isEven(a) {
if(a%2===0){
return true;
}else{
return false;
}
// your code here
};
function isSquare(a) {
if (Number.isInteger(Math.sqrt(a))){
return true;
}else{
return false;
}
// your code here
};
function startsWith(char, string) {
if(string.startsWith(char)){
return true;
}else {
return false;
}
// your code here
};
function containsVowels(string) {
const vowels = ["a" ,"e" ,"i", "o","u","A","B","C","D","E"];
let result=false;
for(let i=0;i<string.length;i++)
if(vowels.includes(string[i])){
result=true;
}
return result;
}
function isLowerCase(string) {
if(string===string.toLowerCase()){
return true;
}else{
return false;
}
// your code here
};
module.exports = {
negate,
both,
either,
none,
one,
truthiness,
isEqual,
isGreaterThan,
isLessThanOrEqualTo,
isOdd,
isEven,
isSquare,
startsWith,
containsVowels,
isLowerCase
};