Skip to content

Instantly share code, notes, and snippets.

@monjer
Last active October 21, 2019 02:46
Show Gist options
  • Select an option

  • Save monjer/bc08a546fcd3197ba4f888a67b481f4f to your computer and use it in GitHub Desktop.

Select an option

Save monjer/bc08a546fcd3197ba4f888a67b481f4f to your computer and use it in GitHub Desktop.
Create array fill with index
const fillArrayWithIndex = (length) => {
return Array.from(Array(length).keys());
}
const fillArray = (start, end) => {
return Array.from(Array(end - start + 1).keys()).map((v)=>v+start);
}
const fillArrayWithStep = (start, end, step=1) => {
return Array.from(Array(end - start + step).keys()).map((v)=>v+start);
}
@monjer

monjer commented Oct 14, 2019

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment