DEV Community

loading...

Coding range() function with plain JavaScript

andrew_losseff profile image Andrew ⚛️ & ☕ ・1 min read

Enjoy the video 😀🙏

Also written version https://losseff.xyz/shorts/0024-javascript/

Discussion (1)

pic
Editor guide
Collapse
alfredosalzillo profile image
Alfredo Salzillo

or like this

function range(startAt, endAt) {
  const size = endAt - startAt + 1
  return Array(size).fill(startAt).map((a, b) => a + b);
}