Last active
October 21, 2019 02:46
-
-
Save monjer/bc08a546fcd3197ba4f888a67b481f4f to your computer and use it in GitHub Desktop.
Create array fill with index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fillArrayWithIndex = (length) => { | |
| return Array.from(Array(length).keys()); | |
| } | |
| const fillArray = (start, end) => { | |
| return Array.from(Array(end - start + 1).keys()).map((v)=>v+start); | |
| } | |
| const fillArrayWithStep = (start, end, step=1) => { | |
| return Array.from(Array(end - start + step).keys()).map((v)=>v+start); | |
| } |
monjer
commented
Oct 14, 2019
Author
- How to create an array containing 1…N
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment