Created
February 10, 2023 16:19
-
-
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
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
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