The inclusive minimum value (starting point of the range)
The inclusive maximum value (ending point of the range)
An array of integers from min to max (inclusive)
// Basic range
range(1, 5); // [1, 2, 3, 4, 5]
// Single number range
range(3, 3); // [3]
// Negative numbers
range(-2, 2); // [-2, -1, 0, 1, 2]
// Invalid range (min > max)
range(5, 1); // [] (empty array)
// Zero-based range
range(0, 4); // [0, 1, 2, 3, 4]
// Useful for iterations
range(1, 3).forEach(i => console.log(`Item ${i}`));
// Outputs: "Item 1", "Item 2", "Item 3"
Generates an array of consecutive integers within a specified range. Both the minimum and maximum values are included in the result. If min is greater than max, an empty array is returned.