Skip to content

Commit 77a7c4e

Browse files
committed
callbacks.js stretch problem
1 parent 9645616 commit 77a7c4e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎assignments/callbacks.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,21 @@ function contains(item, list, cb) {
6262
// contains({'supply': 'chalk'}, items, console.log) // false
6363

6464
/* STRETCH PROBLEM */
65+
const list = ["Lebron", "Steph", "Russell", "Steph", "LeBron"]
6566

6667
function removeDuplicates(array, cb) {
6768
// removeDuplicates removes all duplicate values from the given array.
69+
let deduped = [];
70+
array.forEach(function(element){
71+
if(deduped.includes(element) === false) {
72+
deduped.push(element);
73+
}
74+
});
75+
76+
cb(deduped)
77+
6878
// Pass the duplicate free array to the callback function.
6979
// Do not mutate the original array.
7080
}
81+
82+
removeDuplicates(list, console.log)

0 commit comments

Comments
 (0)