I am working with Angular and have an array named testUsers that contains sample data as shown below:
this.testUsers = [
{email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="94a5d4f2f5fff1baf7fbf9">[email protected]</a>', name: 'A Smith'},
{email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="93a1d3f5f2f8f6bdf0fcfe">[email protected]</a>', name: 'B Johnson'},
{email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="96a5d6f0f7fdf3b8f5f9fb">[email protected]</a>', name: 'C Dobbs', colours:
['green', 'blue', 'red']
},
{email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4d790d2b2c2628632e2220">[email protected]</a>', name: 'D Mew', colours:
['black', 'blue']
}
]
I want to extract the values from the nested 'colours' array and store them in a new array. However, my current attempt results in an array within an array, but I need individual values instead.
How can I modify this function to achieve the desired result?
this.newArray = this.testUsers.map(value => {
return value.colours
});