Created
March 17, 2009 21:27
-
-
Save tj/80770 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
/** | |
* Create a range string which can be evaluated to a native array. | |
* | |
* @param {int} start | |
* @param {int} end | |
* @return {string} | |
* @api public | |
*/ | |
function range(start, end) { | |
s = parseInt(start), e = parseInt(end), b = '[' + s | |
if (e > s) while (++s <= e) b += ',' + s | |
else while (--s >= e) b += ',' + s | |
return b + ']' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment