mardi 21 mai 2019

Functions contains (item,list,cb)

So I am supposed to write how this function is supposed to return a cb for true if the item is in the array. I wrote the following but I checked on MDN and it's wrong. It def looks wrong to me but I know I supposed to include return cb() to the equation. What am I doing wrong?

if(===item){ return cb(true) } else { return cb(false) }

// contains checks if an item is present inside of the given array/list.

function contains(item, list, cb) {

// Pass true to the callback if it is, otherwise pass false.

I am getting an Unexpected token error in the MDN.

Aucun commentaire:

Enregistrer un commentaire