Created
February 22, 2023 17:42
-
-
Save ailequal/60142b331a86dead6b02b741d8d0261e to your computer and use it in GitHub Desktop.
range
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
/** | |
* A simple range function. | |
* | |
* @param start | |
* @param end | |
* @param step | |
*/ | |
export default (start: number, end?: number, step: number = 1): number[] => { | |
const output = []; | |
if ("undefined" === typeof end) { | |
end = start; | |
start = 0; | |
} | |
for (let i = start; i < end; i += step) { | |
output.push(i); | |
} | |
return output; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment