So i'm working on a simple For/in loop exercise from a course i am taking. We have a simple object with 3 properties and we have to create a function that takes 2 parameters - the object name and the item you're looking for.
I made my function and compared to the solution from the teacher and it's exactly the same. The problem is when i try it out in the console, i get an error that accuses the object property is not defined.
The code is as follows:
// Question #2:
// Write a function checkBasket() that lets you know if the item is in the basket or not
const amazonBasket = {
glasses: 1,
books: 2,
floss: 100
}
function checkBasket(basket, lookingFor) {
for(item in basket) {
console.log(item);
if(item === lookingFor) {
return `${lookingFor} is in your basket`;
}
}
return `${lookingfor} is not in your basket`;
}
Would really appreciate any help guys! It's been a tough but enjoyable learning process!
Thanks!
lookingforin you last return you needlookingFor