Skip to content

Commit f86c5b4

Browse files
committed
4.2 but with the faild tests
1 parent 01b5a03 commit f86c5b4

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/functions-and-arrays.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,22 @@ console.log(averageNumbers(numbersAvg));
9191

9292
// Level 2: Array of strings
9393
const wordsArr = ['seat', 'correspond', 'linen', 'motif', 'hole', 'smell', 'smart', 'chaos', 'fuel', 'palace'];
94-
/* const averageWordLength = (wordsArray) => {
94+
function averageWordLength(item) {
95+
let sumLength = 0;
96+
for (let b = 0; b < item.length; b++) {
97+
if (item.length > 1) {
98+
sumLength += item[b].length;
99+
return sumLength
100+
} else if (item.length === 1) {
101+
return item[b].length;
102+
} else {
103+
return null;
104+
}
105+
}
106+
107+
}
95108

96-
} */
109+
console.log(averageWordLength(wordsArr))
97110

98111
// Iteration #5: Unique arrays
99112
const wordsUnique = [

0 commit comments

Comments
 (0)