Skip to content

Commit d9cf49d

Browse files
committed
add solution ironhack-labs#5
1 parent 919f675 commit d9cf49d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/functions-and-arrays.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,18 @@ const wordsUnique = [
9595
'bring'
9696
];
9797

98-
function uniquifyArray() {}
98+
function uniquifyArray(input) {
99+
if (!input || input.length === 0) {
100+
return null;
101+
}
102+
let arrWithoutDuplicates = [];
103+
for (let element of input) {
104+
if (arrWithoutDuplicates.indexOf(element) === -1) {
105+
arrWithoutDuplicates.push(element);
106+
}
107+
}
108+
return arrWithoutDuplicates;
109+
}
99110

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

0 commit comments

Comments
 (0)