7
7
// } else {
8
8
// return num2;
9
9
// }
10
- // }
10
+ // };
11
11
12
12
// ES6
13
13
const maxOfTwoNumbers = ( num1 , num2 ) => {
@@ -20,16 +20,33 @@ const maxOfTwoNumbers = (num1, num2) => {
20
20
21
21
22
22
// Iteration #2: Find longest word
23
- const words = [ 'mystery' , 'brother' , 'aviator' , 'crocodile' , 'pearl' , 'orchard' , 'crackpot' ] ;
23
+ // const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];
24
+
25
+ // const findLongestWord = (a, b) => {
26
+
27
+ // }
28
+
24
29
25
30
// Iteration #3: Calculate the sum
26
31
27
32
const numbers = [ 6 , 12 , 1 , 18 , 13 , 16 , 2 , 1 , 8 , 10 ] ;
28
33
34
+ function sumNumbers ( numbers ) {
35
+ let sum = 0 ; // sum starts at 0
36
+ for ( let i = 0 ; i < numbers . length ; i ++ ) { // loop over array
37
+ sum += numbers [ i ] ; // add every number of array to sum
38
+ }
39
+ return sum ; // when iteration of loop is done, return total of sum
40
+ }
41
+
29
42
// Iteration #4: Calculate the average
30
43
// Level 1: Array of numbers
31
44
const numbersAvg = [ 2 , 6 , 9 , 10 , 7 , 4 , 1 , 9 ] ;
32
45
46
+ function averageNumbers ( numbersAvg ) {
47
+
48
+ } ;
49
+
33
50
// Level 2: Array of strings
34
51
const wordsArr = [ 'seat' , 'correspond' , 'linen' , 'motif' , 'hole' , 'smell' , 'smart' , 'chaos' , 'fuel' , 'palace' ] ;
35
52
0 commit comments