I have an array of objects and I'd like to return an array of all the ids. For example:
const arr = [
{Locations:[{id:2129, Name: 'testAA'}, {id:3431, Name: 'testAB'}, {id:4373, Name: 'testAC'}]},
{Locations:[{id:2545, Name: 'testBA'}, {id:3431, Name: 'testBB'}]}
];
I'd like to return: [2129, 3431, 4373, 2545, 3431]
I've tried to following:
arr.map((value) => {
let newarray = [];
return newarray += value['Locations'].map(ID => ID.id);
});
This returns: ["2129,3431,4373", "2545,3431"]
How do I combine those two arrays?