const target = [1,2,3,4,5,6,7,0];
function work(arr) {
let len = arr.length / 4;
let maxd = 0;
for (let i = 0; i < 4; i++) {
let min = arr[i * len], max = min;
for (let j = i * len; j < (i + 1) * len; j++) {
let num = arr[j];
if (num > max) max = num;
if (num < min) min = num;
}
let d = max - min;
if (d > maxd) maxd = d;
}
return maxd;
}