Created
March 13, 2022 16:49
-
-
Save AitorAlejandro/a3461e4a5d4c5bb9c5c5bec3203119e6 to your computer and use it in GitHub Desktop.
Create an array with a range of numbers
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 start = 0; | |
const end = 100; | |
const step = 10; | |
const arrayLength = Math.floor(((end - start) / step)) + 1; | |
const range = [...Array(arrayLength).keys()].map(x => (x * step) + start); | |
// [0,10,20,30,40,50,60,70,80,90,100] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment