Skip to content
Advertisement

How to filter list of objects that doesn’t match some condition in another list of objects

I have an array of objects of optional working hours of some business (5 min jumps).

In addition, I have an array of objects of appointments.

I want to filter the optional working hours if there is an existing appointment between those hours.

I tried this solution with moment.js library:

JavaScript

Current result: Duplicated available working hours

Expected result: Array of available working hours that don’t overlap with appointments array.

Advertisement

Answer

It’s not so easy, but your check in .some() it wasn’t complete in my opinion. Can you try whit that solution:

JavaScript
JavaScript
Advertisement