Skip to content

Instantly share code, notes, and snippets.

@AitorAlejandro
Created March 13, 2022 16:49
Show Gist options
  • Save AitorAlejandro/a3461e4a5d4c5bb9c5c5bec3203119e6 to your computer and use it in GitHub Desktop.
Save AitorAlejandro/a3461e4a5d4c5bb9c5c5bec3203119e6 to your computer and use it in GitHub Desktop.
Create an array with a range of numbers
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