Skip to content
Advertisement

Group rows on one column and form nested subarray with other column

Here is the thing I trying deal with I have array which looks like this and have duplicates

JavaScript

Result that I need to get is below . I did try different ways to do it but still can bring it to the finel result that have to come up

JavaScript

any suggestion how to do it ?

here is my best solution that I tried

JavaScript

Advertisement

Answer

try this code

JavaScript

your result will be in final_result array

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