We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aaad927 commit 1a56cf2Copy full SHA for 1a56cf2
src/functions-and-arrays.js
@@ -138,7 +138,22 @@ const wordsCount = [
138
'matter'
139
];
140
141
-function howManyTimes() {}
+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
152
+ return 0;
153
154
155
+}
156
+console.log( howManyTimes(wordsCount,"matter") );
157
158
159
0 commit comments