My JavaScript code includes an array of objects structured as follows:
const selection = [
{id: 'P282', areas: ['188']},
{id: 'P277', areas: []},
{id: 'P280'},
{id: 'P281'},
{id: 'P279'},
{id: 'U57', areas: ['190', '189', '188']},
];
I aim to extract all the areas from each user and store them in a separate array that looks like this:
const extractedAreas = ['188', '190', '189', '188']
This new array may include duplicate elements if present.