DEV Community

Jonathan Armentor
Jonathan Armentor

Posted on

1 1

Generating an Inclusive Array Between Two Numbers

I wrote a simple little function using ES6 array methods to generate an inclusive array between two given numbers. Handy for a handful of applications.

Happy to get the community's feedback.

function sequential(to, from = 0) {
    return Array.from(Array(to + 1).keys()).slice(from)
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay