I am currently working on this code, but I keep encountering an error. The main objective is to generate, by the end of the program, an array consisting of arrays that fulfill the condition of having both values greater than the values in the preceding array.
var data = [[68, 150], [70, 155], [55, 160]];
var result = [];
for(i=0; i<data.length; i++){
var firstPosterior = data[i+1][0];
var lastPosterior = data[i+1][1];
var firstAnterior = data[i][0];
var lastAnterior = data[i][1];
if(
firstPosterior > firstAnterior &&
lastPosterior > lastAnterior
) {
result.push(firstPosterior, firstPosterior);
}
}