Write a function `range(start, end)` that returns an array of numbers from start to end (inclusive).
Problem Statement
Write a function `range(start, end)` that returns an array of numbers from start to end (inclusive).
Complexity
Time Complexity: -
Space Complexity: -
Hints
š” Hint 1:
Array.from() can create arrays from array-like objects.
š” Hint 2:
Array.from({ length: n }, (_, i) => ...) creates an array of n elements.
š” Hint 3:
Array.from({ length: end - start + 1 }, (_, i) => start + i);
ā
Solution:
```javascript
function range(start, end) {
return Array.from({ length: end - start + 1 }, (_, i) => start + i);
}
```