Given an array like this:
[
{ id: 1, emailAddresses: ["[email protected]", "[email protected]"] },
{ id: 2, emailAddresses: ["[email protected]" },
{ id: 3, emailAddresses: ["[email protected]", "[email protected]", "[email protected]"]
]
How could I use Javascript to reduce this to an array like this:
[
{ id: 1, emailAddress: "[email protected]" },
{ id: 1, emailAddress: "[email protected]" },
{ id: 2, emailAddress: "[email protected]" },
{ id: 3, emailAddress: "[email protected]" },
{ id: 3, emailAddress: "[email protected]" },
{ id: 3, emailAddress: "[email protected]" }
]
I've read about the functions reduce, flat, map and so on and read lots of the questions on SO about using them but I can't find anything that's asking quite the same as this and I can't get my head around using those functions to do it.