11// 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+ }
59
610// Iteration #2: Find longest word
711const words = [ 'mystery' , 'brother' , 'aviator' , 'crocodile' , 'pearl' , 'orchard' , 'crackpot' ] ;
812
913function findLongestWord ( ) { }
1014
11-
12-
1315// Iteration #3: Calculate the sum
1416const numbers = [ 6 , 12 , 1 , 18 , 13 , 16 , 2 , 1 , 8 , 10 ] ;
1517
1618function sumNumbers ( ) { }
1719
18-
19-
2020// Iteration #3.1 Bonus:
2121function sum ( ) { }
2222
23-
24-
2523// Iteration #4: Calculate the average
2624// Level 1: Array of numbers
2725const numbersAvg = [ 2 , 6 , 9 , 10 , 7 , 4 , 1 , 9 ] ;
2826
2927function averageNumbers ( ) { }
3028
31-
3229// Level 2: Array of strings
3330const wordsArr = [ 'seat' , 'correspond' , 'linen' , 'motif' , 'hole' , 'smell' , 'smart' , 'chaos' , 'fuel' , 'palace' ] ;
3431
35- function averageWordLength ( ) { }
32+ function averageWordLength ( ) { }
3633
3734// Bonus - Iteration #4.1
3835function avg ( ) { }
@@ -54,15 +51,11 @@ const wordsUnique = [
5451
5552function uniquifyArray ( ) { }
5653
57-
58-
5954// Iteration #6: Find elements
6055const wordsFind = [ 'machine' , 'subset' , 'trouble' , 'starting' , 'matter' , 'eating' , 'truth' , 'disobedience' ] ;
6156
6257function doesWordExist ( ) { }
6358
64-
65-
6659// Iteration #7: Count repetition
6760const wordsCount = [
6861 'machine' ,
@@ -80,8 +73,6 @@ const wordsCount = [
8073
8174function howManyTimes ( ) { }
8275
83-
84-
8576// Iteration #8: Bonus
8677const matrix = [
8778 [ 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 = [
10899
109100function greatestProduct ( ) { }
110101
111-
112-
113-
114102// The following is required to make unit tests work.
115103/* Environment setup. Do not modify the below code. */
116104if ( typeof module !== 'undefined' ) {
0 commit comments