Skip to content

Commit eab592a

Browse files
committed
add solution ironhack-labs#7
1 parent 8a9bbcb commit eab592a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/functions-and-arrays.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ function uniquifyArray(input) {
112112
const wordsFind = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience'];
113113

114114
function doesWordExist(arrToSearch, searchedWord) {
115-
if (!arrToSearch || arrToSearch.length === 0) {
116-
return null;
117-
}
115+
// if (!arrToSearch || arrToSearch.length === 0) {
116+
// return null;
117+
// }
118118
for (let word of arrToSearch) {
119119
if (word === searchedWord) {
120120
return true;
@@ -138,7 +138,15 @@ const wordsCount = [
138138
'matter'
139139
];
140140

141-
function howManyTimes() {}
141+
function howManyTimes(arrToSearch, searchedWord) {
142+
let counter = 0;
143+
for (let word of arrToSearch) {
144+
if (word === searchedWord) {
145+
counter++;
146+
}
147+
}
148+
return counter;
149+
}
142150

143151
// Iteration #8: Bonus
144152
const matrix = [

0 commit comments

Comments
 (0)