const data = [
[1, 1, false],
[1, 1, true],
[1, 1, true],
[1, 1, true],
[1, 1, false],
[1, 1, false],
[1, 1, true],
[1, 1, true],
[1, 1, true],
]
const arr = [];
let i = 0;
let isContinueData = false;
data.forEach((item, index) => {
if (index < data.length - 1 && item[2] === data[index + 1][2]) {
if (isContinueData) {
arr[i] = {
...arr[i],
end: index
}
} else {
arr[i] = {
start: index,
end: ''
}
}
isContinueData = true
} else {
isContinueData = false
arr[i] = {
start: index,
...arr[i],
end: index
}
i++;
}
})
console.log(arr)
console