Skip to content

Commit 89044a7

Browse files
committed
Done Iteration ironhack-labs#7: Count Repetition
1 parent 4bed2d4 commit 89044a7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/functions-and-arrays.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,18 @@ const wordsCount = [
194194
'matter'
195195
];
196196

197-
function howManyTimes() {}
197+
function howManyTimes(array, word) {
198+
if (array.length === 0){
199+
return 0
200+
}
201+
let counterWord = 0
202+
for(let i = 0; i < array.length; i++){
203+
if (array[i] === word){
204+
counterWord += 1
205+
}
206+
}
207+
return counterWord
208+
}
198209

199210

200211

0 commit comments

Comments
 (0)