Skip to content

Commit e00624b

Browse files
author
brian ruff
committed
all exercises done with 10 mins till standup
1 parent 532a53d commit e00624b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

assignments/callbacks.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum'];
1+
const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum', 'Notebook'];
22

33
function firstItem(arr, cb) {
44
// firstItem passes the first item of the given array to the callback function.
@@ -43,4 +43,15 @@ function removeDuplicates(array, cb) {
4343
// removeDuplicates removes all duplicate values from the given array.
4444
// Pass the duplicate free array to the callback function.
4545
// Do not mutate the original array.
46+
console.log(cb(array));
4647
}
48+
49+
removeDuplicates(items, (items) => {
50+
let unique = [];
51+
for(let i = 0; i < items.length; i++){
52+
if( !(unique.includes(items[i])) ){
53+
unique.push(items[i]);
54+
}
55+
}
56+
return unique;
57+
});

0 commit comments

Comments
 (0)