Write a function checkBasket() that lets you know if the item is in the basket or not.
Here is the object basket:
amazonBasket = { glasses: 1, books: 2, floss: 100 }
What I tried in my JS:
function checkBasket(basket, lookingFor) { for(item of amazonBasket) { if(lookingFor===item){ console.log("This item is in the basket") }else{ console.log("This item is not in the basket") } }) }checkBasket(amazonbasket, books)
i.e:
checkBasket(amazonbasket,books)
it will return “This item is in the basket”
I don’t understand why books are undefined.
#javascript #objective-c