📌  相关文章
📜  从对象中查找项目 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:53.109000             🧑  作者: Mango

代码示例2
// Objects

let foods = {
  apples: 25,
  oranges: 32,
  plums: 28,
  bananas: 13,
  grapes: 35,
  strawberries: 27,
};

function checkInventory(scannedItem) {
  if (foods[scannedItem] != undefined) return foods[scannedItem];
  return foods;
}

console.log(checkInventory('apples'));