([1, 2, 3, 4, 5, 6, 1, 2, 3], 1, 2, 3 are the parts I wanna get)
let’s say I have a array, [true, true, true, false, false, false, true, true, true], I wanna get the ones that are
truebut using something like a range, since I don't need to get
truenor
false` I need to get strings (which each one is different)
I tried asking Google’s Gemini, and it resulted in this function:
<code>function getSurroundingLines(
rows: string[],
row: number,
rowEnd: number,
contextLength: number
): string[] {
contextLength = Math.min(contextLength, Math.max(row, rows.length - rowEnd));
const startIndex = Math.max(0, row - contextLength);
const endIndex = Math.min(rows.length, rowEnd + contextLength + 1);
return rows.slice(startIndex, endIndex);
}
</code>
<code>function getSurroundingLines(
rows: string[],
row: number,
rowEnd: number,
contextLength: number
): string[] {
contextLength = Math.min(contextLength, Math.max(row, rows.length - rowEnd));
const startIndex = Math.max(0, row - contextLength);
const endIndex = Math.min(rows.length, rowEnd + contextLength + 1);
return rows.slice(startIndex, endIndex);
}
</code>
function getSurroundingLines(
rows: string[],
row: number,
rowEnd: number,
contextLength: number
): string[] {
contextLength = Math.min(contextLength, Math.max(row, rows.length - rowEnd));
const startIndex = Math.max(0, row - contextLength);
const endIndex = Math.min(rows.length, rowEnd + contextLength + 1);
return rows.slice(startIndex, endIndex);
}
and that didn’t help.
and for what I was expecting, I’ve already said that in the details part.