Assuming we have 2 arrays:
array1 has 1 event:
var array1 = [
{
start: '2018-04-24T10:00:00',
end: '2018-04-24T11:00:00',
title: 'Been to Break'
}
];
array2 has 3 events:
var array2 = [
{
start: '2018-04-24T08:00:00',
end: '2018-04-24T10:00:00',
title: 'Lunch'
},
{
start: '2018-04-24T10:00:00',
end: '2018-04-24T11:00:00',
title: 'Break'
},
{
start: '2018-04-24T13:00:00',
end: '2018-04-24T14:00:00',
title: 'Meeting'
}
];
Desired results should be a new array: array3
var array3 = [
{ //event 1
start: '2018-04-24T08:00:00',
end: '2018-04-24T10:00:00',
title: 'Lunch'
},
{ //event 2
start: '2018-04-24T10:00:00',
end: '2018-04-24T11:00:00',
title: 'Been to Break'
},
{ //event 3
start: '2018-04-24T13:00:00',
end: '2018-04-24T14:00:00',
title: 'Meeting'
}
];
You can see from the desired results in array3 that the event 2 in array2 was replaced with the event 1 in array1 since the start and end values are a match.
Can this be done in JavaScript? and what about performance if we have let's say 1000 events to loop through
Thanks
'Breaky'come from?