Skip to content

Instantly share code, notes, and snippets.

@HugoDF
Last active June 26, 2017 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HugoDF/fb3e6bc658c615cdad8752087d2ab14f to your computer and use it in GitHub Desktop.
Save HugoDF/fb3e6bc658c615cdad8752087d2ab14f to your computer and use it in GitHub Desktop.
Takes a start and end value for an integer range and returns an array containing the range.
const range = (first, last) => {
const firstValue = last ? first : 1;
const length = last ? last - first + 1 : first;
return Array.from({ length })
.map((_, i) => i + firstValue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment