Link Search Menu Expand Document

Access Property Names with Bracket Notation

Summary

  • Bracket notation can be used to check a value of a object property.

Final Code

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

function checkInventory(scannedItem) {
  // Only change code below this line
  return foods[scannedItem];
  // Only change code above this line
}

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