loading...

re: How to create range in Javascript VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Yes, excellent solution. This, slimmed down, version also works... const range = (start, end, length = end - start) => Array.from({ length...
 

Almost.

Try:

const range = (start, end, length = end - start + 1) =>
  Array.from({ length }, (_, i) => start + i)
> range(0,2)
[ 0, 1, 2 ]
code of conduct - report abuse