Skip to content

Commit bec97d0

Browse files
committed
Iteration ironhack-labs#6
1 parent 8e7acf9 commit bec97d0

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/functions-and-arrays.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,20 @@ uniquifyArray(wordsUnique);
182182
// Iteration #6: Find elements
183183
const wordsFind = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience'];
184184

185-
function doesWordExist(arrOfWords, searchWord) {
185+
function doesWordExist(array, searchWord) {
186186

187-
if(arrOfWords.length === 0)
188-
{
189-
return null;
190-
}
191-
for(let i = 0; i < arrOfWords.length; i++)
192-
{
193-
if(arrOfWords[i] === searchWord)
187+
if (array.length > 0) {
188+
if (array.includes(searchWord))
194189
{
195190
return true;
196-
}
197-
}
198-
return false;
191+
} else return false;
192+
}
193+
else
194+
{
195+
return null;
196+
}
199197
}
200-
doesWordExist(wordsFind, 'machine');
198+
doesWordExist(wordsFind, 'eating');
201199

202200

203201
// Iteration #7: Count repetition

0 commit comments

Comments
 (0)