Skip to content

Commit 622ebff

Browse files
committed
solved iteration ironhack-labs#5
1 parent 0787a76 commit 622ebff

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/functions-and-arrays.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ function averageWordLength(wordsArr) {
9696
// Bonus - Iteration #4.1
9797
function avg() {}
9898

99+
99100
// Iteration #5: Unique arrays
100101
const wordsUnique = [
101102
'crab',
@@ -111,7 +112,19 @@ const wordsUnique = [
111112
'bring'
112113
];
113114

114-
function uniquifyArray() {}
115+
function uniquifyArray(wordsNotUnique) {
116+
if (wordsNotUnique.length === 0){
117+
return null
118+
}
119+
120+
let wordsUnique = []
121+
for (word of wordsNotUnique) {
122+
if (!wordsUnique.includes(word)) {
123+
wordsUnique.push(word)
124+
}
125+
}
126+
return wordsUnique
127+
}
115128

116129

117130

0 commit comments

Comments
 (0)