The recursive one is really nice. Can be shortened to:
const range = (s, e) => e > s ? [s, ...range(s + 1, e)] : [s];
Also this is another approach, + easier to handle descending sequences too:
const range = (s,e) => e > s ? Array(e - s + 1).fill(0).map((x, y) => y + s) : Array(s - e + 1).fill(0).map((x, y) => - y + s);
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The recursive one is really nice. Can be shortened to:
Also this is another approach, + easier to handle descending sequences too: