Skip to content

Commit 31da52f

Browse files
committed
Adjustments
1 parent 1a56cf2 commit 31da52f

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/functions-and-arrays.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
function maxOfTwoNumbers(num1, num2) {
33
return num1 < num2 ? num2 : num1
44
}
5+
console.log( maxOfTwoNumbers(2,5) ); // 5 =
56

67

78
// Iteration #2: Find longest word
@@ -16,6 +17,8 @@ function findLongestWord(words) {
1617

1718
return longestWord ? longestWord : null;
1819
}
20+
console.log( findLongestWord(words) ); // crocodile =
21+
console.log( findLongestWord([]) ); // null =
1922

2023

2124

@@ -29,6 +32,7 @@ function sumNumbers(numbers) {
2932
}
3033
return sum;
3134
}
35+
console.log( sumNumbers(numbers) ); // 87 =
3236

3337

3438

@@ -59,7 +63,8 @@ const numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9];
5963
function averageNumbers(numbers) {
6064
return numbers.length ? sumNumbers(numbers) / numbers.length : null
6165
}
62-
console.log( averageNumbers(numbersAvg) );
66+
console.log( averageNumbers(numbersAvg) ); // 6 =
67+
console.log( averageNumbers([]) ); // null =
6368

6469

6570
// Level 2: Array of strings
@@ -77,7 +82,8 @@ function averageWordLength(words) {
7782
function avg(mixedArr) {
7883
return mixedArr.length ? sum(mixedArr) / mixedArr.length : null;
7984
}
80-
console.log( avg(mixedArr) ) // should return: 5.7 =
85+
console.log( avg(mixedArr) ) // 5.7 =
86+
console.log( avg([]) ) // null =
8187

8288
// Iteration #5: Unique arrays
8389
const wordsUnique = [
@@ -101,6 +107,8 @@ function uniquifyArray( words ) {
101107
}
102108
return uniqueWords.length ? uniqueWords : null;
103109
}
110+
console.log( uniquifyArray(wordsUnique) ); //
111+
console.log( uniquifyArray([]) ); // null =
104112

105113

106114

@@ -118,8 +126,9 @@ function doesWordExist( words, search ) {
118126
}
119127
}
120128
}
121-
console.log( doesWordExist(wordsFind,"machine") )
122-
console.log( doesWordExist(wordsFind,"machines") )
129+
console.log( doesWordExist(wordsFind,"machine") ) // true =
130+
console.log( doesWordExist(wordsFind,"machines") ) // false =
131+
console.log( doesWordExist([],"machine") ) // null =
123132

124133

125134

@@ -153,7 +162,8 @@ function howManyTimes( words, search ) {
153162
}
154163
}
155164
}
156-
console.log( howManyTimes(wordsCount,"matter") );
165+
console.log( howManyTimes(wordsCount,"matter") ); // 4 =
166+
console.log( howManyTimes([],"matter") ); // 0 =
157167

158168

159169

@@ -181,7 +191,9 @@ const matrix = [
181191
[1, 70, 54, 71, 83, 51, 54, 69, 16, 92, 33, 48, 61, 43, 52, 1, 89, 19, 67, 48]
182192
];
183193

184-
function greatestProduct() {}
194+
function greatestProduct() {
195+
196+
}
185197

186198

187199

0 commit comments

Comments
 (0)