Created
November 24, 2021 14:23
-
-
Save mmoehrlein/652ca678fc3d6032b4e2ccef045a6acb to your computer and use it in GitHub Desktop.
js - generate an array with sequential numbers
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
| /** | |
| * Generate a Array with sequential numbers. | |
| * | |
| * @param start first value | |
| * @param stop last value | |
| * @param step step size | |
| * @returns {Array} | |
| */ | |
| function range(start, stop, step){ | |
| return Array.from({ length: (stop - start) / step + 1}, (_, i) => start + (i * step)); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment