Skip to content
Advertisement

Combining arrays from dictionary in Javascript

I have the following structure:

JavaScript

How can I combine those arrays keeping any duplicates so I will have [1, 2, 3, 3, 4, 6, 6, 6, 7]? I have tried concat but I cannot seem to find a way to do so. I have many more keys so it has to be some loop:

My attempt so far:

JavaScript

Would there be a possible way to avoid this loop?

Advertisement

Answer

You could flat the values from the array.

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