Skip to content

Commit a44280f

Browse files
committed
complete callbacks.js challenge
1 parent 5489815 commit a44280f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

assignments/callbacks.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,28 @@ const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum'];
4141

4242
function getLength(arr, cb) {
4343
// getLength passes the length of the array into the callback.
44+
cb(arr.length);
4445
}
4546

4647
function last(arr, cb) {
4748
// last passes the last item of the array into the callback.
49+
cb(arr.length - 1);
4850
}
4951

5052
function sumNums(x, y, cb) {
5153
// sumNums adds two numbers (x, y) and passes the result to the callback.
54+
cb(x + y);
5255
}
5356

5457
function multiplyNums(x, y, cb) {
5558
// multiplyNums multiplies two numbers and passes the result to the callback.
59+
cb(x * y);
5660
}
5761

5862
function contains(item, list, cb) {
5963
// contains checks if an item is present inside of the given array/list.
6064
// Pass true to the callback if it is, otherwise pass false.
65+
cb(list.includes(item));
6166
}
6267

6368
/* STRETCH PROBLEM */

0 commit comments

Comments
 (0)