Skip to content

Commit bc63888

Browse files
committed
Add Iteration ironhack-labs#6
1 parent 5a37901 commit bc63888

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/functions-and-arrays.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,19 @@ let uniquifyArray = (arr) => {
136136
console.log(uniquifyArray(wordsUnique));
137137
console.log(wordsUnique);
138138

139+
// Iteration #6: Find elements
140+
const wordsFind = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience'];
141+
let doesWordExist = (arr, str) => {
142+
let wordExist = '';
143+
for (let i = 0; i < arr.length; i++){
144+
if (arr[i] === str){
145+
wordExist = true;
146+
break;
147+
} else {
148+
wordExist = false;
149+
}
150+
}
151+
return wordExist;
152+
}
153+
console.log(doesWordExist(words, 'subset'));
154+

0 commit comments

Comments
 (0)