re: How to create range in Javascript VIEW POST

FULL DISCUSSION
 
function range(start, end) {
  return [...Array((end - start) + 1).keys()].map(val => val + start);
}
 

Or one-liner:

const range = (start, end) => [...Array(end - start + 1)].map((_, i) => start + i)
code of conduct - report abuse