Created
July 22, 2017 08:42
-
-
Save alex-cory/c6d64de4838ca4caf69af75f98b7e9f3 to your computer and use it in GitHub Desktop.
Generate Array [0, ...., N] Function
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
// Option 1: [0, ...., N] | |
var array = length => Array.from({ length }, (_, i) => i) | |
// Option 2: [0, ...., N] | |
var array = to => Array.from(Array(to), (_, i) => i) | |
// Option 3: [1, ....., N] | |
var array = length => Array.from({ length }, (_, i) => i + 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment