Skip to content

Commit 4bed2d4

Browse files
committed
Done Iteration ironhack-labs#6: Find elements
1 parent fd66ffe commit 4bed2d4

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
@@ -160,7 +160,22 @@ function uniquifyArray(array) {
160160
// Iteration #6: Find elements
161161
const wordsFind = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience'];
162162

163-
function doesWordExist() {}
163+
function doesWordExist(array,word) {
164+
if (array.length === 0){
165+
return null
166+
}
167+
let onlyArray = []
168+
for (let i = 0; i < array.length; i++){
169+
if (onlyArray.indexOf(array[i]) === -1){
170+
onlyArray.push(array[i])
171+
}
172+
}
173+
if (onlyArray.includes(word)){
174+
return true
175+
}else{
176+
return false
177+
}
178+
}
164179

165180

166181

0 commit comments

Comments
 (0)