Skip to content

Instantly share code, notes, and snippets.

@tj
Created March 17, 2009 21:27
Show Gist options
  • Save tj/80770 to your computer and use it in GitHub Desktop.
Save tj/80770 to your computer and use it in GitHub Desktop.
/**
* 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