1
1
// Iteration #1: Find the maximum
2
2
function maxOfTwoNumbers ( aNumber , anotherNumber ) {
3
- if ( aNumber > anotherNumber ) {
3
+ if ( aNumber > anotherNumber ) {
4
4
return aNumber ;
5
5
}
6
6
return anotherNumber ;
7
7
}
8
8
9
-
10
-
11
9
// Iteration #2: Find longest word
12
10
const words = [ 'mystery' , 'brother' , 'aviator' , 'crocodile' , 'pearl' , 'orchard' , 'crackpot' ] ;
13
11
14
12
function findLongestWord ( input ) {
15
- if ( ! input || input . length == 0 ) {
13
+ if ( ! input || input . length == 0 ) {
16
14
return null ;
17
15
}
18
- let longestWord = "" ;
19
- for ( word of input ) {
20
- if ( word . length > longestWord . length ) {
16
+ let longestWord = '' ;
17
+ for ( word of input ) {
18
+ if ( word . length > longestWord . length ) {
21
19
longestWord = word ;
22
20
}
23
21
}
24
22
return longestWord ;
25
23
}
26
24
27
-
28
-
29
25
// Iteration #3: Calculate the sum
30
26
const numbers = [ 6 , 12 , 1 , 18 , 13 , 16 , 2 , 1 , 8 , 10 ] ;
31
27
32
28
function sumNumbers ( ) { }
33
29
34
-
35
-
36
30
// Iteration #3.1 Bonus:
37
31
function sum ( ) { }
38
32
39
-
40
-
41
33
// Iteration #4: Calculate the average
42
34
// Level 1: Array of numbers
43
35
const numbersAvg = [ 2 , 6 , 9 , 10 , 7 , 4 , 1 , 9 ] ;
44
36
45
37
function averageNumbers ( ) { }
46
38
47
-
48
39
// Level 2: Array of strings
49
40
const wordsArr = [ 'seat' , 'correspond' , 'linen' , 'motif' , 'hole' , 'smell' , 'smart' , 'chaos' , 'fuel' , 'palace' ] ;
50
41
51
- function averageWordLength ( ) { }
42
+ function averageWordLength ( ) { }
52
43
53
44
// Bonus - Iteration #4.1
54
45
function avg ( ) { }
@@ -70,15 +61,11 @@ const wordsUnique = [
70
61
71
62
function uniquifyArray ( ) { }
72
63
73
-
74
-
75
64
// Iteration #6: Find elements
76
65
const wordsFind = [ 'machine' , 'subset' , 'trouble' , 'starting' , 'matter' , 'eating' , 'truth' , 'disobedience' ] ;
77
66
78
67
function doesWordExist ( ) { }
79
68
80
-
81
-
82
69
// Iteration #7: Count repetition
83
70
const wordsCount = [
84
71
'machine' ,
@@ -96,8 +83,6 @@ const wordsCount = [
96
83
97
84
function howManyTimes ( ) { }
98
85
99
-
100
-
101
86
// Iteration #8: Bonus
102
87
const matrix = [
103
88
[ 8 , 2 , 22 , 97 , 38 , 15 , 0 , 40 , 0 , 75 , 4 , 5 , 7 , 78 , 52 , 12 , 50 , 77 , 91 , 8 ] ,
@@ -124,9 +109,6 @@ const matrix = [
124
109
125
110
function greatestProduct ( ) { }
126
111
127
-
128
-
129
-
130
112
// The following is required to make unit tests work.
131
113
/* Environment setup. Do not modify the below code. */
132
114
if ( typeof module !== 'undefined' ) {
0 commit comments