Skip to content

Commit ecb6a9e

Browse files
committed
changes to ironhack-labs#7 after talking to pedro
1 parent 734854a commit ecb6a9e

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/functions-and-arrays.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,23 +187,20 @@ function howManyTimes(Arr, searchElement) {
187187
}
188188

189189
let count = {};
190-
let result = [];
191190
Arr.forEach(searchElement => {
192191
if (count[searchElement]) {
193192
count[searchElement] +=1
194193
return
195194
}
196195
count[searchElement] = 1
197196
})
198-
199-
for (let prop in count){
200-
if (count[prop] >=2){
201-
result.push(prop)
202-
}
197+
198+
if(count[searchElement]){
199+
return count[searchElement]
203200
}
204-
return count[searchElement]
205-
201+
return 0
206202
}
203+
console.log(howManyTimes(wordsCount, "matter"));
207204

208205
console.log(howManyTimes(wordsCount, "dare"));
209206

0 commit comments

Comments
 (0)