Skip to content

Commit 782d2a0

Browse files
committed
1 parent 4ed711e commit 782d2a0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/functions-and-arrays.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,19 @@ const wordsCount = [
128128
];
129129

130130
function howManyTimes(arrCount, search) {
131+
let count = 0
131132
for (let i = 0;i < arrCount.length; i++){
132-
return arrCount.indexOf(search)
133+
if(arrCount[i] === search){
134+
return count + 1;
135+
} else {
136+
continue;
137+
}
133138
}
139+
return count
134140
}
135141
console.log(howManyTimes(wordsCount, 'matter'))
136142

137143

138-
139144
// Iteration #8: Bonus
140145
const matrix = [
141146
[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8],

0 commit comments

Comments
 (0)