I guess it is more a logical problem, but it also concerns reduce method (I guess it is a proper method to that kind of issue).
Here are my 3 arrays:
const availableHours = [ 9, 10, 11, 12, 13, 14 ];
const exArr1 = [ 9, 10, 11, 12, 13, 14 ]
const exArr2 = [ 10, 11, 12, 13 ]
The first one represents all available hours. The user always books two of them, being next to each other (f.ex. 9and10, 13and14, 10and11, and so on...) in any configuration. Now, if user books all three sets (i.e. 9-10, 11-12, 13-14) I need to return true. It means the day is full booked. But also if it is booked f.ex. like that 10-11 and 12-13 it also should return true, as those hours which have been left unbooked (9 and 14) cannot be booked as they are single hours. Both example arrays should return true.
Can you help on that one? I tried to do that with reduce method but could not do that.
Thank you!
availableHours.join('') === exArr1.join('')?truewhen no other appointments could be made for that day[9, 11, 13])