Build an Inventory Management Program - Build an Inventory Management Program

Tell us what’s happening:

pls help me to figure it out. 7,8, 10, 14,15,16 aren’t pass, idk why. I have try in another complier and it’s work. PLLLSSSS helpppp mmeeee.

Your code so far

let inventory=[]
  
  
  function findProductIndex(product){
    return inventory.findIndex(item => item.name === product.toLowerCase())
    
  }
  
  
  function addProduct(productObj){
    let flag = false
    
    for(let prop of inventory){
      if(prop.name === productObj.name.toLowerCase()){
        
        prop.quantity += productObj.quantity
        flag =true
        console.log(inventory)
        return console.log(`${productObj.name.toLowerCase()} quantity updated`);
        
      }
      break
    }
    if(!flag){
      inventory.push({name : productObj.name.toLowerCase(), quantity : productObj.quantity})
      console.log(`${productObj.name.toLowerCase()} added to inventory`)
    
    }
    console.log(inventory)
   return 
  }
  
function removeProduct(nameProduct, quantity){
 
  for(let prep1 of inventory){
    if(prep1.name ===  nameProduct.toLowerCase() && prep1.quantity > 1){
     if(quantity > prep1.quantity){
       let index = inventory.findIndex(item => item.name === nameProduct)
       inventory.splice(index, 1)
     }
     
     else{prep1.quantity -= quantity
       return `Remaining ${nameProduct} pieces: ${prep1.quantity}`
     }
     return;
    }
    
    else if(prep1.name === nameProduct.toLowerCase() && prep1.quantity <= 1){
     let index = inventory.findIndex(item => item.name === nameProduct)
     
      inventory.splice(index, 1)
      return `Not enough ${nameProduct} available, remaining pieces: ${prep1.quantity}`
    }
  
  }
 
  return  console.log(`${nameProduct.toLowerCase()} not found`)

}





Your browser information:

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

Challenge Information:

Build an Inventory Management Program - Build an Inventory Management Program
https://www.freecodecamp.org/learn/full-stack-developer/lab-inventory-management-program/build-an-inventory-management-program

try writing

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

below your code, and consider what you see in the console

I have updated my code yesterday, and another task passed except 15, and 16

flour added to inventory
flour quantity updated
choco added to inventory
choco quantity updated

please share your updated code if you need more help