Skip to content

Commit f1afd46

Browse files
committed
Iteration ironhack-labs#6: Find elements
1 parent 3c8fa3c commit f1afd46

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/functions-and-arrays.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,31 @@ const wordsUnique = [
167167
'bring'
168168
];
169169

170-
function uniquifyArray() {}
170+
function uniquifyArray(words) {
171+
if (!words.length) {
172+
return null;
173+
}
174+
let uniques = [];
175+
for (let word of words) {
176+
while (!uniques.includes(word)) {
177+
uniques.push(word)
178+
}
179+
}
180+
return uniques;
181+
}
171182

172183

173184

174185
// Iteration #6: Find elements
175186
const wordsFind = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience'];
176187

177-
function doesWordExist() {}
188+
function doesWordExist(words, word) {
189+
if (!words.length) {
190+
return null
191+
}
192+
193+
return words.includes(word)
194+
}
178195

179196

180197

0 commit comments

Comments
 (0)