I want to parse my array to 4 equal intervals. For example, array [12, 48] parse to 4 intervals [12,21], [21, 30], [30, 39], [39, 48]. I could only parse my Array to pairs (code here). But I don't know how to do what I want.
var arrayTest = [];
for (var i = 0; i < 1000; i++) arrayTest[i] = i;
var ab = [2, 6];
start = ab[0];
finish = ab[1];
var ab_new = [];
for (var i = start; i <= finish; i++) ab_new[i]= arrayTest[i];
var output = [];
for (var i = start; i < ab_new.length - 1; ++i) {
output[i] = [];
output[i].push(ab_new[i]);
output[i].push(ab_new[i + 1]);
}
console.log(output);
My output is:
[ , , [ 2, 3 ], [ 3, 4 ], [ 4, 5 ], [ 5, 6 ] ]
9like from [12, 21] ?