DEV Community

Discussion on: 🔥 Create number ranges in JavaScript

Collapse
joshuakb2 profile image
Joshua Baker

I always copy and paste one of these:

function range(n) {
    let r = [];
    for (let i = 0; i < n; i++) r.push(i);
    return r;
}
Enter fullscreen mode Exit fullscreen mode
Collapse
domhabersack profile image
Dom Habersack Author

Nice yes, putting this in a helper function is definitely the way to go.