I'm trying to compare the name to the item names in the list and return the price of that item but it's not going through the full list. Can someone explain to me what I'm doing wrong and how to correct it?
let items = [
{
itemName: "Effective Programming Habits",
type: "book",
price: 13.99
},
{
itemName: "Creation 3005",
type: "computer",
price: 299.99
},
{
itemName: "Finding Your Center",
type: "book",
price: 15.00
}
]function priceLookup (itemsList, name) {
let price = null;
for (item of itemsList) {
if (item.itemName === name) {
price = item.price;
}
else { price = "No item found with that name";
}
}
return price;
}