So, if you all you really want to do is to be able to test if a number is within 5 of a sentinel multiple, then I don't think you really want to be generating a giant array and using .includes(). That would be slow. If you were going to pre-generate values, you should use a Set and then use .has() which should be a lot faster than .includes() for a large set of data.
But, it seems to be that you can just calculate a lot faster without doing any pre-generation at all:.
In the code below, we divide by the multiple (140) and then look at the remainder. If the remainder is <=5 or >= 135, then it's within 5 of the multiple, otherwise not. It's really that simple. Since it appears you don't want the numbers 0-5 (around the zero multiple) to be counted as true, we add a special case for those.
// tests to see if a value is within 5 of a multiple of 140 const multiple = 140; const over = 5; const below = multiple - over; function testValue(val) { if (val < below) return false; const delta = val % multiple; // divide by multiple, get remainder return (delta <= over || delta >= below); // see if remainder in right range } // run some tests on numbers at edges of the interval ranges [ 0, 1, 134, 135, 140, 144, 145, 146, // around 140 274, 275, 280, 284, 285, 286, // around 280 414, 415, 420, 424, 425, 426, // around 420 554, 555, 560, 564, 565, 566 // around 560 ].forEach(num => { console.log(`${num}: ${testValue(num)}`); });