I have a javascript array like so:
var recipients = [{
name: 'Michael',
task: 'programming',
contactdetails: '[email protected]'
}, {
name: 'Michael',
task: 'designing',
contactdetails: '[email protected]'
}, {
name: 'Shane',
task: 'designing',
contactdetails: '[email protected]'
}];
What I am doing is a rostering system where I send out notifications for who is on for this week, so the email is like "Hi Michael you are programming this week". At the moment it is not great because it sends out an email for every value in the array. So in the above instance it would send Michael 2 emails.
What I would like to do is remove duplicates while merging the task property strings. So the array would be:
var recipients = [{
name: 'Michael',
task: 'programming, designing',
contactdetails: '[email protected]'
}, {
name: 'Shane',
task: 'designing',
contactdetails: '[email protected]'
}];
that way it can just send one message like "Hi Michael you are programming, designing this week". How do I go about this? I also am using Google Apps script so I need a pure javascript solution. I should also add that the name and email address for each person will always be identical, so Michael will never have a different email address etc. Your help is much appreciated!
contactdetails
field only? or both thecontactdetails
ANDname
fields?