Skip to content

Instantly share code, notes, and snippets.

@yashsway
Created February 10, 2023 16:19
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 yashsway/4d2fc61e2e6eb30a3992189cc131132c to your computer and use it in GitHub Desktop.
Save yashsway/4d2fc61e2e6eb30a3992189cc131132c to your computer and use it in GitHub Desktop.
Creates an empty array of set length and fills it with a sequence of numbers, with a customizable step
const range = (start, end, step = 1) => {
let output = [];
if (typeof end === 'undefined') {
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