Skip to content

Commit 7733e5e

Browse files
committed
Iteration ironhack-labs#7: Count repetition - DONE
1 parent b471925 commit 7733e5e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/functions-and-arrays.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,23 @@ const wordsCount = [
198198
'disobedience',
199199
'matter'
200200
];
201+
let theWord2 = 'subset';
201202

202-
function howManyTimes() {}
203-
203+
function howManyTimes(wordsCount, theWord2) {
204+
let theAnswer = false
205+
let theCounter = 0
206+
if (theWord === '' || wordsCount.length === 0) {
207+
return theCounter
208+
} else {
209+
for (let i=0; i < wordsCount.length; i++) {
210+
if (theWord2 === wordsCount[i]) {
211+
theAnswer = true
212+
theCounter += 1
213+
}
214+
}
215+
return theCounter
216+
}
217+
}
204218

205219

206220
// Iteration #8: Bonus

0 commit comments

Comments
 (0)