jeudi 1 septembre 2016

How to merge element in looped array if some of the element is in another array?

I have an array like this:

var arr = [
        [11, 12, 13, 14], 
        [1, 2, 3, 4], 
        [3, 4, 5], 
        [5, 6, 7, 8],
        [6, 7, 8 , 9]
];

I would like to concatenate array that has value in another array and remove its duplicates so in this case it should output:

var arr = [
            [11, 12, 13, 14], 
            [1, 2, 3, 4, 5, 6, 7, 8, 9] 

    ];

Any help would be appreciated. Thank you!

Aucun commentaire:

Enregistrer un commentaire