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
}