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.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.
re: How to create range in Javascript VIEW POST
FULL DISCUSSIONIt 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.