Skip to content

Instantly share code, notes, and snippets.

@samthomson
Created April 27, 2021 11:43
Show Gist options
  • Save samthomson/7adc9458669a69fae36ccf6bd9f5eeca to your computer and use it in GitHub Desktop.
Save samthomson/7adc9458669a69fae36ccf6bd9f5eeca to your computer and use it in GitHub Desktop.
delta to array index ensuring within bounds
const newIndex = (items.length + currentIndex + delta) % items.length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment