@@ -2,61 +2,63 @@ const { nums, words } = require("./data/data.js");
2
2
3
3
// Every
4
4
const isEveryNumGreaterThan2 = ( ) => {
5
- //
5
+ return nums . every ( ( num ) => num >= 2 ) ;
6
6
} ;
7
7
8
8
const isEveryWordShorterThan7 = ( ) => {
9
- //
9
+ return words . every ( ( word ) => word . length < 7 ) ;
10
10
} ;
11
11
12
12
// Filter
13
13
14
14
const arrayLessThan5 = ( ) => {
15
- //
15
+ return nums . filter ( ( num ) => num < 5 ) ;
16
16
} ;
17
17
18
18
const arrayOddLengthWords = ( ) => {
19
- //
19
+ return words . filter ( ( word ) => word . length % 2 === 1 ) ;
20
20
} ;
21
21
22
22
// Find
23
23
24
24
const firstValDivisibleBy4 = ( ) => {
25
- //
25
+ return nums . find ( ( num ) => num % 4 === 0 ) ;
26
26
} ;
27
27
28
28
const firstWordLongerThan4Char = ( ) => {
29
- //
29
+ return words . find ( ( word ) => word . length > 4 ) ;
30
30
} ;
31
31
32
32
// For Each
33
33
34
34
const logValuesTimes3 = ( ) => {
35
- //
35
+ return nums . forEach ( ( num ) => console . log ( ( num *= 3 ) ) ) ;
36
36
} ;
37
37
38
38
const logWordsWithExclamation = ( ) => {
39
- //
39
+ return words . forEach ( ( word ) => console . log ( ` ${ word } !` ) ) ;
40
40
} ;
41
41
42
42
// Map
43
43
44
44
const arrayValuesSquaredTimesIndex = ( ) => {
45
- //
45
+ return nums . map ( ( num , index ) => {
46
+ return Math . pow ( num , 2 ) * index ;
47
+ } ) ;
46
48
} ;
47
49
48
50
const arrayWordsUpcased = ( ) => {
49
- //
51
+ return words . map ( ( word ) => word . toUpperCase ( ) ) ;
50
52
} ;
51
53
52
54
// Some
53
55
54
56
const areSomeNumsDivisibleBy7 = ( ) => {
55
- //
57
+ return nums . some ( ( num ) => num % 7 === 0 ) ;
56
58
} ;
57
59
58
60
const doSomeWordsHaveAnA = ( ) => {
59
- //
61
+ return words . some ( ( word ) => word . toLowerCase ( ) . includes ( "a" ) ) ;
60
62
} ;
61
63
62
64
module . exports = {
0 commit comments