Build an Inventory Management Program - Build an Inventory Management Program

Tell us what’s happening:

I do not understand why my addProduct function is not passing, can anybody help please…

Your code so far

const inventory = [];
const findProductIndex = (productName) =>{
  for(let i =0; i < inventory.length; i++){
    if(inventory[i].name.toLowerCase() === productName.toLowerCase() ){
      return i
    }
   
  }
   return -1
}
console.log(findProductIndex("lol"))

const addProduct = (productObject) =>
{
  let found = false;
    for(let i = 0; i < inventory.length; i++){
      if(  productObject.name.toLowerCase()
    === inventory[i].name.toLowerCase())
      {
        inventory[i].quantity =  inventory[i].quantity + productObject.quantity;
        console.log(`${productObject.name} quantity updated`);
      found = true;
      }
    }if(found === false){
    inventory.push(productObject);
        console.log(`${productObject.name} added to inventory`)
    }
 
  
}
console.log(addProduct({name: "FLOUR", quantity: 5},
))

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

try to call the function twicr

addProduct({name: "FLOUR", quantity: 5})
addProduct({name: "FLOUR", quantity: 5})

it prints

FLOUR added to inventory
FLOUR quantity updated

notice how that is not what the function should print. The test says it should be flour quantity updated. Do you see the difference?

The cases. Thank you man