Skip to content

Commit 2830873

Browse files
ishish
ish
authored and
ish
committed
1 parent 092f412 commit 2830873

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/functions-and-arrays.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,20 @@ const wordsCount = [
166166
'matter'
167167
];
168168

169+
// function howManyTimes (wordsArr, wordSearch) {
170+
// return wordsArr.filter( a => a == wordSearch).length
171+
// }
172+
173+
function howManyTimes (wordsArr, wordSearch) {
174+
let count = 0
175+
for (let i=0; i < wordsArr.length; i++) {
176+
if ( wordSearch == wordsArr[i]) {
177+
count += 1
178+
}
179+
}
180+
return count;
181+
}
182+
169183
// Iteration #8: Bonus
170184

171185
const matrix = [

0 commit comments

Comments
 (0)