I have a array map function which helps me reduce an array of objects down to a simple string.
const formatEmails: (arr: { "default" : string }[]) => string = (arr: { "default" : string }[]) =>
arr.map(e => e["default"]).reduce((e, i) => e + i + "; ", "");
this outputs me the actual email address with out the default. But what if my email looks like this and does not only have default as a key ?
person_emails: [{ "default": '[email protected]' }, { "home": '[email protected]' }, { "work": '[email protected]' }]
How would i go about that and how can i generate a string of for example "default:[email protected]; home:[email protected]; work:[email protected]"
Also just to be clear my code calls the function formatEmails everytime we read a row on the data export like this
args.rowData["person_emails"] = formatEmails(args.rowData["person_emails"]);