Skip to content

Commit fa6c6d4

Browse files
committed
finished callbacks assignment
1 parent d192ca8 commit fa6c6d4

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

assignments/callbacks.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,33 @@ const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum'];
2424

2525
function getLength(arr, cb) {
2626
// getLength passes the length of the array into the callback.
27+
return cb(arr.length);
2728
}
2829

2930
function last(arr, cb) {
3031
// last passes the last item of the array into the callback.
32+
return b(arr[arr.length-1]);
3133
}
3234

3335
function sumNums(x, y, cb) {
3436
// sumNums adds two numbers (x, y) and passes the result to the callback.
37+
// let sumz = x + y;
38+
return cb(x + y);
3539
}
36-
40+
sumNums(2,3,'console.log');
3741
function multiplyNums(x, y, cb) {
3842
// multiplyNums multiplies two numbers and passes the result to the callback.
43+
return cb(x,y);
3944
}
4045

4146
function contains(item, list, cb) {
4247
// contains checks if an item is present inside of the given array/list.
4348
// Pass true to the callback if it is, otherwise pass false.
49+
return cb(item,list);
4450
}
4551

52+
53+
4654
/* STRETCH PROBLEM */
4755

4856
function removeDuplicates(array, cb) {

0 commit comments

Comments
 (0)