I need to check if the given time range is available or not.
Array with busy hours:
[
{ from: 2, to: 4 },
{ from: 8, to: 10 }
]
The compartment I want to check
{ from: 3, to: 6 }
Expected result:
{ from: 1, to: 2 } // true
{ from: 5, to: 7 } // true
{ from: 3, to: 4 } // false
{ from: 9, to: 10 } // false
for
loop of some kind. What have you tried? Please show your best attempt and explain what went wrong (errors, unexpected results, etc.)