Skip to content

Instantly share code, notes, and snippets.

@tj

tj/gist:80770

Created Mar 17, 2009
Embed
What would you like to do?
/**
* 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
You can’t perform that action at this time.