Skip to content

Instantly share code, notes, and snippets.

@dbrockman
Created May 13, 2015 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbrockman/88e4e3258eed0617be7d to your computer and use it in GitHub Desktop.
Save dbrockman/88e4e3258eed0617be7d to your computer and use it in GitHub Desktop.
function modulo(a, b) {
var r = a % b;
return (r * b < 0) ? r + b : r;
}
function nthArrayItem(array, n) {
return array[modulo(n, array.length)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment