Skip to content

Commit ef30a8c

Browse files
committed
Add Iteration ironhack-labs#7
1 parent bc63888 commit ef30a8c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/functions-and-arrays.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,29 @@ let doesWordExist = (arr, str) => {
152152
}
153153
console.log(doesWordExist(words, 'subset'));
154154

155+
// Iteration #7: Count repetition
156+
const wordsCount = [
157+
'machine',
158+
'matter',
159+
'subset',
160+
'trouble',
161+
'starting',
162+
'matter',
163+
'eating',
164+
'matter',
165+
'truth',
166+
'disobedience',
167+
'matter'
168+
];
169+
170+
let howManyTimes = (arr, word) => {
171+
let counter = 0;
172+
arr.forEach((el) => {
173+
if( word === el){
174+
counter++;
175+
}
176+
}); return counter
177+
}
178+
179+
console.log(howManyTimes(wordsCount, 'matter'));
180+

0 commit comments

Comments
 (0)