Skip to content

Commit 43b01f1

Browse files
authored
Update step4-bonus.js
1 parent 24868eb commit 43b01f1

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Week3/homework/step4-bonus.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
const values = ['a', 'b', 'c', 'd', 'a', 'e', 'f', 'c'];
44

55
// Add your function here. Try and come up with a good name for this function
6+
uniqueArray = values.filter(function duplicateRemover (item, pos) {
7+
return values.indexOf(item) == pos;
8+
})
9+
console.log(uniqueArray);
610

711
// Replace `yourFunction` with the name of the function you just created
8-
const uniqueValues = yourFunction(values);
12+
const uniqueValues = duplicateRemover(values);
913

1014
console.log(uniqueValues);
15+
16+
//another solution
17+
18+
[... new Set(values)];
19+
console.log([... new Set(values)]);

0 commit comments

Comments
 (0)