Group same object key in array javascript : I have data like this :

    [
        {
            "ru":"R401",
            "tot":[1, 1, 1, 1],
            "unit":["OFFSITE","OFFSITE","OFFSITE","RCU"]
        }
    ]

I want to groupping the object 'tot' and 'unit' then push it into a new array if the 'tot' and 'unit' is same, but my logic is bad.

And I want the output become like this :

    [
        {
            "ru":"R401",
            "tot":[1, 1],
            "unit":["OFFSITE","RCU"]
        }
    ]

How can I did it ? some people wanna help me ? thx before it.

