Open this example in the interactive library
Source code
const rows = [
{ line: "Red", start: 8, end: 10 },
{ line: "Blue", start: 9, end: 11 },
{ line: "Red", start: 12, end: 15 },
{ line: "Gold", start: 15, end: 16 },
];
const result = Array.from({ length: 9 }, (_, i) => i + 8).filter(
(hour) => !rows.some((r) => r.start <= hour && hour < r.end),
);
console.log(JSON.stringify(result, null, 2));
Sample output
[ 11, 16 ]
