Skip to content

Commit 333792d

Browse files
authored
Merge pull request #1 from daniela1362/daniela-arias-ordonez
Commit new changes
2 parents bc4a039 + 7a6e4b4 commit 333792d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

assignments/callbacks.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,32 @@ const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum'];
2626

2727

2828
function getLength(arr, cb) {
29-
// getLength passes the length of the array into the callback.
29+
cb(arr.length);
3030
}
3131

32+
getLength(items,function (first){
33+
console.log(length)
34+
});
35+
3236
function last(arr, cb) {
33-
// last passes the last item of the array into the callback.
37+
return cb(arr[arr.length-1])// last passes the last item of the array into the callback.
3438
}
39+
last(items,function(lastitem){
40+
console.log(lastitem)
41+
});
3542

3643
function sumNums(x, y, cb) {
44+
return cb([x+y])
3745
// sumNums adds two numbers (x, y) and passes the result to the callback.
3846
}
3947

4048
function multiplyNums(x, y, cb) {
49+
return cb([x*y])
4150
// multiplyNums multiplies two numbers and passes the result to the callback.
4251
}
4352

4453
function contains(item, list, cb) {
54+
cb(list.includes(item))
4555
// contains checks if an item is present inside of the given array/list.
4656
// Pass true to the callback if it is, otherwise pass false.
4757
}

0 commit comments

Comments
 (0)