1
1
// Iteration #1: Find the maximum
2
- function maxOfTwoNumbers ( ) { }
3
-
4
-
2
+ function maxOfTwoNumbers ( num1 , num2 ) {
3
+ if ( num1 > num2 ) {
4
+ return num1 ;
5
+ } else {
6
+ return num2 ;
7
+ }
8
+ }
5
9
6
10
// Iteration #2: Find longest word
7
11
const words = [ 'mystery' , 'brother' , 'aviator' , 'crocodile' , 'pearl' , 'orchard' , 'crackpot' ] ;
8
12
9
13
function findLongestWord ( ) { }
10
14
11
-
12
-
13
15
// Iteration #3: Calculate the sum
14
16
const numbers = [ 6 , 12 , 1 , 18 , 13 , 16 , 2 , 1 , 8 , 10 ] ;
15
17
16
18
function sumNumbers ( ) { }
17
19
18
-
19
-
20
20
// Iteration #3.1 Bonus:
21
21
function sum ( ) { }
22
22
23
-
24
-
25
23
// Iteration #4: Calculate the average
26
24
// Level 1: Array of numbers
27
25
const numbersAvg = [ 2 , 6 , 9 , 10 , 7 , 4 , 1 , 9 ] ;
28
26
29
27
function averageNumbers ( ) { }
30
28
31
-
32
29
// Level 2: Array of strings
33
30
const wordsArr = [ 'seat' , 'correspond' , 'linen' , 'motif' , 'hole' , 'smell' , 'smart' , 'chaos' , 'fuel' , 'palace' ] ;
34
31
35
- function averageWordLength ( ) { }
32
+ function averageWordLength ( ) { }
36
33
37
34
// Bonus - Iteration #4.1
38
35
function avg ( ) { }
@@ -54,15 +51,11 @@ const wordsUnique = [
54
51
55
52
function uniquifyArray ( ) { }
56
53
57
-
58
-
59
54
// Iteration #6: Find elements
60
55
const wordsFind = [ 'machine' , 'subset' , 'trouble' , 'starting' , 'matter' , 'eating' , 'truth' , 'disobedience' ] ;
61
56
62
57
function doesWordExist ( ) { }
63
58
64
-
65
-
66
59
// Iteration #7: Count repetition
67
60
const wordsCount = [
68
61
'machine' ,
@@ -80,8 +73,6 @@ const wordsCount = [
80
73
81
74
function howManyTimes ( ) { }
82
75
83
-
84
-
85
76
// Iteration #8: Bonus
86
77
const matrix = [
87
78
[ 8 , 2 , 22 , 97 , 38 , 15 , 0 , 40 , 0 , 75 , 4 , 5 , 7 , 78 , 52 , 12 , 50 , 77 , 91 , 8 ] ,
@@ -108,9 +99,6 @@ const matrix = [
108
99
109
100
function greatestProduct ( ) { }
110
101
111
-
112
-
113
-
114
102
// The following is required to make unit tests work.
115
103
/* Environment setup. Do not modify the below code. */
116
104
if ( typeof module !== 'undefined' ) {
0 commit comments