I've an array like this:
const myArray = ['Item1', 'Item3', 'Item5'];
And an object list like that:
ObjectsList: {
Item1: ["A", "B", "C"],
Item2: ["A", "D", "E"],
Item3: ["B", "E", "C", "G"],
Item4: ["B", "C", "R"],
Item5: ["D"],
Item6: ["F", "D", "E"],
Item7: ["A", "E", "L", "M"],
}
I want to get the values of all the keys with the same name of my array elements and push them into a new array without duplicate elements.
In the case of my provided example I want to get the Item1, Item3, Item5 keys values and push them in a new array avoiding duplicates. The result should be that: [A, B, C, E, G, D]
Which is the best way to do that in JavaScript? Thanks in advance.