-
Notifications
You must be signed in to change notification settings - Fork 274
/
Copy pathcore.js
53 lines (44 loc) · 1004 Bytes
/
core.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
// Check to see if all elements in an array
// are even numbers.
function allEven(input){
for(let i = 0; i < input.length; i++) {
if(input[i] % 2 !== 0){
return false;
}
}
return true;
}
// Check to see if all elements in an array
// are of the same type.
function allSameType (input) {
for(let i = 1; i < input.length; i++) {
if(typeof input[i] !== typeof input[i-1]){
return false;
}
}
return true;
};
// Check to see if every element in the matrix is
// an array and that every element in the array is
// greater than 0.
function positiveMatrix(input) {
for (let i = 0; i < input.length; i++) {
for (var j = 0; j < 3; j++) {
if (input[i][j] <= 0) {
return false;
}
}
}
return true;
};
// Check that all items in an array are strings
// and that they all only contain the same vowels.
function allSameVowels (input) {
return input;
};
module.exports = {
allEven,
allSameType,
positiveMatrix,
allSameVowels
};