I have one array with response like this:
let firstArray = {
        "TEST0":[
                    "App",
                    "Desktop",
                    "Mobile"
        ],
        TEST1": [
                    "BEVERAGES",
                    "CLOTHING, PERSONAL ACCESSORIES AND RELATED PRODUCTS"
        ]
    }
And I have array of objects like this:
 let secondArray =  [
        {
            created: "2019-05-28T11:13:55.000"
            createdBy: ""
            displayname: "BEVERAGES"
            docname: "BEVERAGES"
            id: 1
            name: "BEVERAGES"
            purposeCode: "P"
            responsible: (2) [{…}, {…}]
            shortname: "BEVERAGES"
            status: "Active"
        },
        {
            created: "2019-05-28T11:13:55.000"
            createdBy: ""
            displayname: "CLOTHING, PERSONAL ACCESSORIES AND RELATED PRODUCTS"
            docname: "CLOTHING, PERSONAL ACCESSORIES AND RELATED PRODUCTS"
            id: 2
            name: "CLOTHING, PERSONAL ACCESSORIES AND RELATED PRODUCTS"
            purposeCode: "P"
            responsible: []
            shortname: "CLOTHING, PERSONAL ACCESSORIES AND RELATED PRODUCTS"
            status: "Active"
        }
    ]
I want to check where that displayname from second array belongs in first array, and group them BY KEYS like that
For example :
if i have BEVERAGES, APP, and so i will have structure like this:
{
    "TEST0":[   
                "App",
                "Desktop",
                "Mobile"
    ],
    TEST1": [
                "BEVERAGES":[
                {
                    created: "2019-05-28T11:13:55.000"
                    createdBy: ""
                    displayname: "BEVERAGES"
                    docname: "BEVERAGES"
                    id: 1
                    name: "BEVERAGES"
                    purposeCode: "P"
                    responsible: (2) [{…}, {…}]
                    shortname: "BEVERAGES"
                    status: "Active"
                }
            ]
    ]
}
My question is different because i have two arrays and not one, where i want to make one array and group second array by keys from first array
 
     
     
     
    