Created
December 26, 2016 22:00
-
-
Save mhingston/2480919403a6fbe5098108e8a623ff03 to your computer and use it in GitHub Desktop.
Python's range() for javascript
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, stop, step) => | |
{ | |
const output = []; | |
if(stop === undefined) | |
{ | |
stop = start; | |
start = 0; | |
} | |
if(step === undefined) | |
{ | |
step = 1; | |
} | |
for(let i=start; start < stop ? i < stop : i > stop; 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