📅  最后修改于: 2022-03-11 14:59:12.882000             🧑  作者: Mango
function priceLookup(items, name) {
for (let i = 0; i < items.length; i++) {
if (name === items[i].itemName) {
// the return will break the loop and exit the function
return items[i].price;
}
}
// if loop completes no matches were found
return "No item found with that name"
}