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.
info1, info2, info3, etc? Are those all standalone variables too? (if you meant to use strings, strings need delimiters) You should also post the code you've tried that isn't working