It rather depends, Jason, on what you mean by cooler.
If you only needed range to handle approx. 6000 iterations then I think a recursive range function is pretty cool, but slow:
const range = (s,e) => (s === e) ? [s] : [s, ...range(s+1,e)]
But, if you need a much bigger range and fast executuion then do something like this:
const range = (s=0,e=10,r=[]) => {while(e >= s){ r.push(s); (e>=s)? s++ : s--; } return r }
And if you don't like the arrow function, then it's easy to convert to a standard es5 style function.
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.
It rather depends, Jason, on what you mean by cooler.
If you only needed range to handle approx. 6000 iterations then I think a recursive range function is pretty cool, but slow:
But, if you need a much bigger range and fast executuion then do something like this:
And if you don't like the arrow function, then it's easy to convert to a standard es5 style function.