phuocng / 1loc

What's your favorite JavaScript single LOC (line of code)?

Home Page:https://phuoc.ng/collection/1-loc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create an array of numbers in the given range

ksrakhilesh opened this issue · comments

Should Be
const range1 = (min, max) => Array(max - min + 1).fill(0).map((_, i) => min + i);

@ksrakhilesh Yes, both returns the same result. Actually, I used the same approach initially.

Anyway, I updated the post using both ways.

Just curious: Is there a benefit on either approach?

@martinschilliger No, it's the same. It's just another way to describe.