Skip to content

Commit 153151b

Browse files
committed
iteration ironhack-labs#7
1 parent cd43119 commit 153151b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/functions-and-arrays.js

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

166-
function howManyTimes() {}
166+
function howManyTimes(arr, wordToCount) {
167+
const isEmptyArr = arr.length === 0;
168+
if (isEmptyArr) {
169+
return 0;
170+
} else {
171+
if (doesWordExist(arr, wordToCount)) {
172+
let wordCounter = 0;
173+
for (word of arr) {
174+
const isToFindingWord = wordToCount === word;
175+
if (isToFindingWord) {
176+
wordCounter++;
177+
}
178+
}
179+
return wordCounter;
180+
} else {
181+
return 0;
182+
}
183+
}
184+
}
167185

168186
// Iteration #8: Bonus
169187
const matrix = [

0 commit comments

Comments
 (0)