Open this example in the interactive library
Source code
type Row = { line: string; start: number; end: number };
const rows: Row[] = [
{ 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 = rows.filter((r) => r.start <= 9 && 9 < r.end).map((r) => r.line);
console.log(JSON.stringify(result, null, 2));
Sample output
[ "Red", "Blue" ]
