Skip to content

Commit 0c17c34

Browse files
committed
ft(implement callback to check if item is in an array)
1 parent 6c6233d commit 0c17c34

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎assignments/callbacks.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,14 @@ multiplyNums(5, 8, callback);
6767
function contains(item, list, cb) {
6868
// contains checks if an item is present inside of the given array/list.
6969
// Pass true to the callback if it is, otherwise pass false.
70+
if (list.includes(item)) {
71+
cb(true)
72+
} else {
73+
cb(false)
74+
}
7075
}
76+
// Function Invocation
77+
contains('Gum', items, callback);
7178

7279
/* STRETCH PROBLEM */
7380

0 commit comments

Comments
 (0)