Skip to content

Commit 47e7cf5

Browse files
committed
Done Iteration 7
1 parent fa464f2 commit 47e7cf5

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/functions-and-arrays.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,21 @@ const wordsCount = [
163163
"matter",
164164
];
165165

166-
function howManyTimes() {}
166+
function howManyTimes(wordArray, wordToSearch) {
167+
if (wordArray.length == 0) {
168+
return 0;
169+
} else {
170+
i = 0;
171+
count = 0;
172+
while (i < wordArray.length) {
173+
if (wordArray[i] === wordToSearch) {
174+
count++;
175+
}
176+
i++;
177+
}
178+
return count;
179+
}
180+
}
167181

168182
// Iteration #8: Bonus
169183
const matrix = [

0 commit comments

Comments
 (0)