Skip to content

Commit 1a56cf2

Browse files
committed
Complete: ironhack-labs#7
1 parent aaad927 commit 1a56cf2

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/functions-and-arrays.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,22 @@ const wordsCount = [
138138
'matter'
139139
];
140140

141-
function howManyTimes() {}
141+
function howManyTimes( words, search ) {
142+
if ( !words.length ) {
143+
return 0
144+
} else {
145+
if ( words.includes(search) ) {
146+
let count = 0
147+
for ( let word of words ) {
148+
word === search ? count++ : false;
149+
}
150+
return count
151+
} else {
152+
return 0;
153+
}
154+
}
155+
}
156+
console.log( howManyTimes(wordsCount,"matter") );
142157

143158

144159

0 commit comments

Comments
 (0)