Skip to content

Commit 5a37901

Browse files
committed
Add Iteration ironhack-labs#5
1 parent fcf67c2 commit 5a37901

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/functions-and-arrays.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,34 @@ let avg = (arr) => {
105105

106106
console.log(avg(mixedArr));
107107

108+
// Iteration #5: Unique arrays
109+
const wordsUnique = [
110+
'crab',
111+
'poison',
112+
'contagious',
113+
'simple',
114+
'bring',
115+
'sharp',
116+
'playground',
117+
'poison',
118+
'communion',
119+
'simple',
120+
'bring'
121+
];
122+
let uniquifyArray = (arr) => {
123+
for(let i=0; i< arr.length; i++){
124+
for (let n=0; n<arr.length;n++){
125+
if (i !== n){
126+
if (arr[i] === arr[n]){
127+
arr.splice(n,1);
128+
}
129+
} else{
130+
continue;
131+
}
132+
}
133+
}
134+
return `Array updated`;
135+
}
136+
console.log(uniquifyArray(wordsUnique));
137+
console.log(wordsUnique);
138+

0 commit comments

Comments
 (0)