File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -72,8 +72,6 @@ function sum(num) {
7272 suma += num [ i ]
7373
7474 }
75-
76-
7775 }
7876
7977 return suma
@@ -117,7 +115,14 @@ function averageWordLength(wordsArr) {
117115console . log ( averageWordLength ( wordsArr ) )
118116
119117// Bonus - Iteration #4.1
120- function avg ( ) { }
118+ function avg ( words ) {
119+
120+ let result = sum ( words ) / words . length
121+
122+ return result
123+ }
124+
125+ console . log ( avg ( mixedArr ) )
121126
122127// Iteration #5: Unique arrays
123128const wordsUnique = [
@@ -182,9 +187,25 @@ const wordsCount = [
182187 'disobedience' ,
183188 'matter'
184189] ;
190+ const wordCount = "truth"
191+
192+ function howManyTimes ( words , word ) {
193+
194+ let count = 0
195+
196+ for ( let i = 0 ; i < words . length ; i ++ ) {
197+
198+ if ( words [ i ] === word ) {
199+
200+ count += 1
185201
186- function howManyTimes ( ) { }
202+ }
203+ }
187204
205+ return count
206+
207+ }
208+ console . log ( howManyTimes ( wordsCount , wordCount ) )
188209
189210
190211// Iteration #8: Bonus
You can’t perform that action at this time.
0 commit comments