Skip to content

Commit 17a420a

Browse files
committed
Finished project 4
1 parent 1f2b704 commit 17a420a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/project-4.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,30 @@ const getLastItem = (collection, cb) => {
1515

1616
const sumNums = (x, y, cb) => {
1717
// Write a function called sumNums that adds two numbers and passes the result to the callback
18+
cb(x + y);
1819
};
1920

2021
const multiplyNums = (x, y, cb) => {
2122
// Write a function called multiplyNums that multiplies two numbers and passes the result to the callback
23+
cb(x * y);
2224
};
2325

2426
const contains = (collection, item, cb) => {
2527
// Write a function called contains that checks if an item is present inside of the given array.
2628
// Pass true to the callback if it is, otherwise pass false
29+
cb(collection.includes(item));
2730
};
2831

2932
const removeDuplicates = (collection, cb) => {
3033
// Write a function called removeDuplicates that removes all duplicate values from the given array.
3134
// Pass the array to the callback function. Do not mutate the original array.
35+
const arr = [];
36+
for (let i = 0; i < collection.length; i++) {
37+
if (!arr.includes(collection[i])) {
38+
arr.push(collection[i]);
39+
}
40+
}
41+
cb(arr);
3242
};
3343

3444
module.exports = {

0 commit comments

Comments
 (0)