Last active
March 2, 2021 08:34
-
-
Save acidDrain/42bb5d5e8100669ec3d907caa7a1fa74 to your computer and use it in GitHub Desktop.
Generate an array of length n in JavaScript
This file contains 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 generateRange = rangeLength => Array.from({ length: rangeLength }, (_,i) => i); | |
console.log(generateRange(20)); | |
[ | |
0, 1, 2, 3, 4, 5, 6, | |
7, 8, 9, 10, 11, 12, 13, | |
14, 15, 16, 17, 18, 19 | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment