Skip to content

Commit 24837ac

Browse files
committed
iteration ironhack-labs#5
1 parent 80246dc commit 24837ac

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
@@ -119,7 +119,22 @@ const wordsUnique = [
119119
'bring'
120120
];
121121

122-
function uniquifyArray() {}
122+
function uniquifyArray(arrOfWords) {
123+
124+
if (arrOfWords.length === 0) return null;
125+
126+
let uniqeArray = [];
127+
let wordCounter = 1;
128+
129+
arrOfWords.forEach(word => {
130+
if (!uniqeArray.includes(word)) {
131+
uniqeArray.push(word);
132+
}
133+
});
134+
135+
return uniqeArray.length === arrOfWords ? arrOfWords : uniqeArray;
136+
137+
}
123138

124139

125140

0 commit comments

Comments
 (0)