Skip to content

Commit b2d07da

Browse files
luismunoz83luismunoz83
luismunoz83
authored and
luismunoz83
committed
Iteration ironhack-labs#6: Find elements
1 parent 8860676 commit b2d07da

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/functions-and-arrays.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,9 @@ const wordsUnique = [
136136

137137
function uniquifyArray(wordsUnique) {
138138

139-
let wordsNew = []
139+
const dataArr = new Set(wordsUnique);
140140

141-
for (let i = 0; i < wordsUnique.length; i++) {
142-
143-
if (wordsUnique[i] !== wordsUnique[i] + 1){
144-
145-
146-
147-
}
148-
}
141+
let wordsNew = Array.from(dataArr)
149142

150143
return wordsNew
151144

@@ -156,10 +149,24 @@ console.log(uniquifyArray(wordsUnique))
156149

157150
// Iteration #6: Find elements
158151
const wordsFind = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience'];
152+
const word = "subset"
153+
154+
function doesWordExist(words, word) {
155+
156+
for (let i = 0; i < words.length; i++) {
157+
158+
if (words[i] === word){
159159

160-
function doesWordExist() {}
160+
return true
161161

162+
}
163+
}
164+
165+
return false
166+
167+
}
162168

169+
console.log(doesWordExist(wordsFind, word))
163170

164171
// Iteration #7: Count repetition
165172
const wordsCount = [

0 commit comments

Comments
 (0)