Last active
June 26, 2017 19:09
-
-
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.
This file contains 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 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