Uncaught ReferenceError: books is not defined

Uncaught ReferenceError: books is not defined

Write a function checkBasket() that lets you know if the item is in the basket or not.

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.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

How to send an object array from c# to javascript?

Im trying to send an array that contains some objects via connection made in SignalR, the connection is not a problem, everything works fine. When the data arrives to the view it is no longer the array i need to use. This is the class:

How to create objects in JavaScript

In this article, we will see the different ways to instantiate objects in JavaScript.

Getting Started with JavaScript Object

Objects in JavaScript, just as in many other programming languages, can be compared to objects in real life. The concept of objects in JavaScript can be understood with real life, tangible objects.