This function generates an array of numbers within a specified range.
JavaScript:
let range = (start, end) => Array.from({length: end - start + 1}, (_, i) => start + i);
// Example
console.log(range(1, 5)); // [1, 2, 3, 4, 5]
console.log(range(10, 15)); // [10, 11, 12, 13, 14, 15]
TypeScript:
let range = (start: number, end: number): number[] => Array.from({length: end - start + 1}, (_, i) => start + i);
// Example
console.log(range(1, 5)); // [1, 2, 3, 4, 5]
console.log(range(10, 15)); // [10, 11, 12, 13, 14, 15]