Skip to content

Instantly share code, notes, and snippets.

@ahmedghazi
Created October 31, 2022 15:39
Show Gist options
  • Save ahmedghazi/0167749c0ce65a9e606a71a90c44ecd2 to your computer and use it in GitHub Desktop.
Save ahmedghazi/0167749c0ce65a9e606a71a90c44ecd2 to your computer and use it in GitHub Desktop.
Modulo
export const modulo = (n, length) => {
n = (n + 1) % length
return n
}
const index = 0
const length = 20
const nextIndex = modulo(index, length)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment