In the example code below I want to filter numbersArray based on different intervals. An interval is defined by a combination of 2 arrays with the lower and upper bound of said interval. How do I identify matches or non-matches like below?
const numbersArray = [1,2,3,4,5,6,7,8,9,10];
const lowerBound = [1, 4, 8];
const higherBound = [3, 6, 10];
If the code works the following test should return true:
matches == [2, 5, 9];
nonmatches == [1, 3, 4, 6, 7, 8, 10];
Assume the arrays contains more than 1000 items and that the numbers doesn't follow any pattern.
Below is a less readable but more realistic scenario.
let numbersArray = [];
let lowerBound = [];
let higherBound = [];
for (let i = 0; i< 1000; i++){
numbersArray.push(i);
}
for(let i = 0; i < 100; i++) {
lowerBound.push(i * 10);
higherBound.push((i * 10) + Math.random() * 10);
}