Skip to content

Commit 0bf9f86

Browse files
committed
iteration ironhack-labs#7
1 parent 78add35 commit 0bf9f86

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/functions-and-arrays.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,22 @@ const wordsCount = [
168168
'matter'
169169
];
170170

171-
function howManyTimes() {}
171+
function howManyTimes(arrOfWords, wordToSearch) {
172+
if (!arrOfWords.length) return 0;
173+
174+
let wordCount = 0;
175+
176+
arrOfWords.forEach((word, i) => {
177+
let currentWord = arrOfWords[i];
178+
179+
if (currentWord === wordToSearch) {
180+
wordCount += 1;
181+
}
182+
});
183+
184+
return wordCount;
185+
186+
}
172187

173188

174189

0 commit comments

Comments
 (0)