DEV Community

Andrew ⚛️ & ☕
Andrew ⚛️ & ☕

Posted on

Coding range() function with plain JavaScript

Enjoy the video 😀🙏

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

Top comments (1)

Collapse
 
alfredosalzillo profile image
Alfredo Salzillo • Edited

or like this

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