Created
August 19, 2019 09:20
-
-
Save dormd/246d43c52ce4a3e740e2a47048499312 to your computer and use it in GitHub Desktop.
This file contains 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
function range(start, end, step) { | |
const results = []; | |
if (end === undefined) { | |
end = start; | |
start = 0; | |
} | |
if (step === undefined) { | |
step = (start < end) ? 1 : -1; | |
} | |
for (let num = start; (step > 0 && num < end) || (step < 0 && num > end); num += step) results.push(num); | |
return results; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment