DEV Community

Discussion on: 1 line of code: How to create a range array

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ

Not really a one-liner, but it is possible to make a range syntax like this in JS:

1[to(6)]   // [1, 2, 3, 4, 5, 6]
9[to(5)]   // [9, 8, 7, 6, 5]
2[to(8, {step: 2})]   // [2, 4, 6, 8]
Enter fullscreen mode Exit fullscreen mode

If you want to know how - take a look at my post

Collapse
 
martinkr profile image
Martin Krause

Amazing series!

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ

More to come when I have some time: String and Array extensions

Thread Thread
 
martinkr profile image
Martin Krause

nice!