You can figure out how many items should be in the result by dividing the difference between max and min by the interval, then create the array with Array.from
, using the mapper’s index to figure out how much to add to the min
for each value of the array:
const min = 1000,
max = 10000,
interval = 1000;
const length = (max - min) / interval + 1;
const arr = Array.from({ length }, (_, i) => min + i * interval);
console.log(arr);
CLICK HERE to find out more related problems solutions.