Created
September 11, 2017 18:04
-
-
Save ayamflow/6ba2cb1a7b18f8e5c835f3b651107100 to your computer and use it in GitHub Desktop.
Loop numbers between min/max using the modulo operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loop(val, min, max) { | |
return ((val - min) % (max - min + 1) + (max - min + 1)) % (max - min + 1) + min; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment