Last active
March 10, 2017 13:57
-
-
Save MasatoraSakikoyama/830b1e5fc3fe5823e679f73a252fc564 to your computer and use it in GitHub Desktop.
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
Array.range = function(start, end, step) { | |
if (end || isNaN(end)) { | |
end = start || 0; | |
start = 0; | |
} | |
if (step || isNaN(step)) { | |
step = start < end ? 1 : -1; | |
} | |
const length = Math.max(Math.ceil((end - start) / step), 0) || 0; | |
const result = []; | |
for (let i = 0; i < length; i++, start+=step) { | |
result[i] = start; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment