Skip to content

Instantly share code, notes, and snippets.

@ailequal
Created February 22, 2023 17:42
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 ailequal/60142b331a86dead6b02b741d8d0261e to your computer and use it in GitHub Desktop.
Save ailequal/60142b331a86dead6b02b741d8d0261e to your computer and use it in GitHub Desktop.
range
/**
* 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