Skip to content

Commit c9e0cc8

Browse files
committed
Iteration ironhack-labs#7: Count repetition
1 parent f1afd46 commit c9e0cc8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/functions-and-arrays.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ function doesWordExist(words, word) {
189189
if (!words.length) {
190190
return null
191191
}
192-
192+
193193
return words.includes(word)
194194
}
195195

@@ -210,7 +210,15 @@ const wordsCount = [
210210
'matter'
211211
];
212212

213-
function howManyTimes() {}
213+
function howManyTimes(words, searchWord) {
214+
let countWord = 0;
215+
for (let word of words) {
216+
if (word === searchWord) {
217+
countWord++
218+
}
219+
}
220+
return countWord
221+
}
214222

215223

216224

0 commit comments

Comments
 (0)