Build an Inventory Management Program - Build an Inventory Management Program

Tell us what’s happening:

My code is returning NAN but I am not sure why because it is not Nan when I log an identical operation to the log.

here property = banana,

Console.log(property) returns banana, inventory.banana returns 1, except inventory.property returns NAN dispite being equal to inventory.banana therefore I am stuck on how to iterate over key values and am not sure why the inventory.property is not working.

Your code so far

let inventory = {banana: 1, apple: 5, pear: 2, grape: 3};
const object = { 
  a: 1
 , apple: 7, apple: 2, c: 3 };




function addProduct(productObject){
  const mergedObject = Object.assign({}, inventory, productObject)
 
  
  for (const property in inventory) {
    let quantityCount = inventory.property;
    console.log(property)
    console.log(inventory.banana)
    console.log(inventory.property)
    console.log(quantityCount)
   
}


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build an Inventory Management Program - Build an Inventory Management Program

It’s about dot v bracket notation, as explained in this FCC article.

Essentially, you can only use dot notation for a static key value (i.e. the literal value of a key in an object). If you are using a dynamic key value, as when you store a value in a variable and then use that variable to access the object key, you must use bracket notation.