DEV Community

Discussion on: How to create range in Javascript

Collapse
 
danielboll profile image
Daniel Boll

I'm a little late for the discussion 😅 but I found the different ways interesting, I ended up getting this one. Is it valid?

const range = (start, end, length = end - start + 1) => [...Array(length).keys()].map(d => d + start) 
Collapse
 
ycmjason profile image
YCM Jason

Looks great to me!