Q:

How do i split an array based on subarray element state?

I have an array consisting of sub arrays:
myArray  = [[info1, info2, info3, value1], [info1, info2, info3, value1], 
[info1, info2, info3, value1],.............]

I want to split the array into several arrays based on "value1". If value1 is above 1000 in more then 5 consecutive elements i want to create a new array:
mySubArray1 = [[info1, info2, info3, 1011], [info1, info2, info3, 
1012], [info1, info2, info3, 1011],.............]

and so if i discover a second series of elements where value1 is above 1000 in more then 5 consecutive elements i want to create another array:
mySubArray2 = [[info1, info2, info3, 3030], [info1, info2, info3, 
4000], [info1, info2, info3, 1700],.............]

What i have done is the following:
var j;
for (j = 0; j < array.length; j++) {
if (array[j][3] < 1000 ) {

    console.log("below 1000");
}
else {
    console.log("above 1000");
}

}

This detects where value is above 1000, but now i need to sort it into new arrays, and i don't know how to start that process.

A:

You should be able to do an Array.reduce to get the desired result: 
I'm generating an array that should be like your input, the value of 'value1' will be between 995 and 1010.

function getRandomInt(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

let myArray  = [...Array(100).keys()].map(n => ['info1', 'info2', 'info3', getRandomInt(995, 1010)]);

console.log("Input: ", JSON.stringify(myArray));

let subArray = [];
// Result will contain a list of our new subarrays.
let result = myArray.reduce((acc, val, index) => {

   if (val[3] >= 1000) { 
      subArray.push(val);
   } 

   if ((val[3] < 1000) || (index === myArray.length - 1) /* Handle the case when we're at the end of myArray */ ) {
       if (subArray.length > 5) { 
           acc.push(subArray);
       } 
       subArray = [];
   }
 
   return acc;
}, [])

console.log("Result:");
result.forEach( (subArray, n) => console.log(`Subarray ${n+1}: `, subArray));

