Skip to content

Instantly share code, notes, and snippets.

@fupslot
Last active May 22, 2016 14:45
Show Gist options
  • Save fupslot/340e6d4fb5d3e869471dcb46f6adbad8 to your computer and use it in GitHub Desktop.
Save fupslot/340e6d4fb5d3e869471dcb46f6adbad8 to your computer and use it in GitHub Desktop.
var currentIndex = 0;
var listLength = 9;
var dir = 1; // -1 - to go backwards
var nextIndex = ((currentIndex + listLength) + dir) % listLength;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment