Created
June 30, 2020 15:33
-
-
Save cesalberca/651c3a19d728150d87a98b9635091099 to your computer and use it in GitHub Desktop.
Range function that returns an array from a given number to another
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
export function range(start: number, end?: number): number[] { | |
return [...Array(end !== undefined ? end - start : start).keys()].map(i => i + (end !== undefined ? start : 0)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment