Skip to content
Advertisement

Javascript – Group array of objects by array of keys

I have this problem, I want to group array of objects, each containing type array, into object of arrays.

Start:

JavaScript

Desired result

JavaScript

Where I am stuck, not sure how to now map that type array 😀 Currently just have a.type[0], which is bad.

JavaScript

Advertisement

Answer

You need to loop over all the elements of a.type.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement