File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,20 +15,30 @@ const getLastItem = (collection, cb) => {
1515
1616const 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
2021const 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
2426const 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
2932const 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
3444module . exports = {
You can’t perform that action at this time.
0 commit comments