Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Find item from objects

// 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'));
 
PREVIOUS NEXT
Tagged: #Find #item #objects
ADD COMMENT
Topic
Name
9+1 =