Skip to content

Instantly share code, notes, and snippets.

@KimSarabia
Last active October 31, 2017 20:18
Show Gist options
  • Save KimSarabia/7e54f0858506b211822d855d2411ba6d to your computer and use it in GitHub Desktop.
Save KimSarabia/7e54f0858506b211822d855d2411ba6d to your computer and use it in GitHub Desktop.
Print Range in JavaScript (ES6)
//Print 1 to 20 (Source: https://stackoverflow.com/questions/3895478/does-javascript-have-a-method-like-range-to-generate-an-array-based-on-suppl)
Array.from(new Array(20), (x,i) => i)
//Result: [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