I have a page where we can add available time slots for a given item. These time slots can be added to any order, but a selected slot should not overlap with other slots. So, before I save I need to validate all the added time slots are overlapping or not with each other. My plan is to add two forloops for this. But I'm wondering there is another way of doing this more efficiently with less coding. Please share your thoughts on this.
In the given image 09:00 - 11:00 is overlapping with 08:00 - 10:00. So it should not allow saving.
I'm trying to add a for loop like below which is not completed. I wonder there is another way of doing this easily.
function isAnOverlapEvent (inputs) {
var i;
var matchingList;
for (i = 0; i < inputs.length; i++) {
var item = inputs[i];
matchingList = inputs;
matchingList.splice(item.index, 1);
for (k = 0; k < matchingList.length; k++) {
}
}
return false;
}
Can someone help me with this?