generateRange
Write a function that generates an array containing all integers in a specified range (inclusive).
Examples
generateRange(1, 5) → [1, 2, 3, 4, 5]
generateRange(-2, 2) → [-2, -1, 0, 1, 2]
generateRange(5, 5) → [5]
Starter code
function generateRange(start, end) {
}
Complexity of the optimal solution
Time O(n), space O(n). The time complexity is proportional to the number of elements in the range (n = end - start + 1). The space complexity is also O(n) as it creates an array to store all the numbers in the range.