Once again, I'm looking at this particular answer.
var firstEvents = events.reduce(function(ar, e) {
var id = e.getId();
if (e.isRecurringEvent() && e.isAllDayEvent() && !ar.some(function(f) {return f.eventId == id})) {
ar.push({eventTitle: e.getTitle(), eventId: id, startDate: e.getAllDayStartDate(), endDate: e.getAllDayEndDate()});
}
return ar;
}, []);
If I want to obtain an array with the event titles as keys (Strings) and the start dates as values (Date objects), so that I can access a specific start date through firstEvents['some event title']
, what modifications do I need to make?
EDIT:
Current Output:
firstEvents = [{eventTitle=Event title 1, <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="244152414a506d40195c5d5e1564434b4b4348410a474b49">[email protected]</a>, startDate=Sun Mar 18 00:00:00 GMT+01:00 2018, endDate=Mon Mar 19 00:00:00 GMT+01:00 2018},
{eventTitle=Event title 2, <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="791c0f1c170d301d440100034b391e16161e151c571a1614">[email protected]</a>, startDate=Tue Mar 19 00:00:00 GMT+01:00 2019, endDate=Wed Mar 20 00:00:00 GMT+01:00 2019},
{eventTitle=Event title 3, <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f49182919a80bd90c98c8d8ec7b4939b9b939891da979b99">[email protected]</a>, startDate=Fri Mar 20 00:00:00 GMT+01:00 2020, endDate=Sat Mar 21 00:00:00 GMT+01:00 2020}]
Desired Output (Pseudo):
firstEvents = ['Event title 1' => Sun Mar 18 00:00:00 GMT+01:00 2018,
'Event title 2' => Tue Mar 19 00:00:00 GMT+01:00 2019,
'Event title 3' => Fri Mar 20 00:00:00 GMT+01:00 2020]