How to add data to a Jason attribute?

I was making an inventory system and I was trying to add a way to add items without them being pre-defined. I had inventory items stored into a json attribute so I needed a way to add data into the attribute.
Here is what I had so far:

if (!PlayerInventory.items[obj]){
         PlayerInventory.items.push(
             {
                 obj: 0,
                 "Type": type,
             }
         )
         PlayerInventory.items[obj] += 1
    }
    if (PlayerInventory.items[obj]){
         PlayerInventory.items[obj] += 1
    }
1 Like

The fix to this was to just do

if (!PlayerInventory.items[obj]){
         PlayerInventory.items[obj](
             {
                 obj: 0,
                 "Type": type,
             }
         )
         PlayerInventory.items[obj].count += 1
    }
    if (PlayerInventory.items[obj]){
         PlayerInventory.items[obj].count += 1
    }