Saturday, 8 April 2017

Creating array with certain type and adding items under it

I'm creating a array with weapon type. Example: Bayonet and each item which has a name type Bayonet in it should be added under there.

Here is code for creating the type:

var weaponType = item.split(' | ');
weaponType = weaponType[0];
budgetSkins[weaponType] = [];

But I'm not sure how can I add it there under the right weaponType. I tried using a if budgetSkins[weaponType] but that doesn't work of course because I have to check for the root name but I'm not sure how could I do that.

Here is example weapon types: Bayonet M9 Bayonet Karambit

Example items: Bayonet | White Karambit | Yellow M9 Bayonet | Golden

What I'm trying to achieve

{
    "M9 Bayonet": [
        "M9 Bayonet | White"
    ],
    "Bayonet": [
        "Bayonet | Golden"
    ]
}



via Jordn

No comments:

Post a Comment