A loop or two will do. We need to compare all pairs to all others.
let arrayFrom = ['1', '6.1', '10', '31', '6.2', 3];
let arrayTo = ['2', '9.9', '30', '401', '7', 5];
function is_pair_included(a, in_b) {
return (a[0] > in_b[0] && a[1] < in_b[1])
}
var to_remove = [];
for (var i = 0; i < arrayFrom.length - 1; i++) {
for (var j = i + 1; j < arrayFrom.length; j++) {
var pair1 = [+arrayFrom[i], +arrayTo[i]];
var pair2 = [+arrayFrom[j], +arrayTo[j]];
if (is_pair_included(pair1, pair2)) {
to_remove.push(i);
}
if (is_pair_included(pair2, pair1)) {
to_remove.push(j);
}
}
}
to_remove.forEach(function(i) {
var pair1 = [+arrayFrom[i], +arrayTo[i]];
console.log("" + pair1, "invalid");
})
solved Two Number Is in between range in array jquery