Last active
May 14, 2021 11:17
-
-
Save novogrammer/b33c249430adb87b771a9eb1f60878f2 to your computer and use it in GitHub Desktop.
Pythonのrangeっぽいやつ
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, stop) { | |
if (stop == null) { | |
return range(0, start); | |
} | |
if (stop < start) { | |
throw new Error("stop < start"); | |
} | |
return [...Array(stop - start).keys()].map((e) => e + start); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment