Created
December 27, 2016 05:48
-
-
Save geraldyeo/14818564c14f2ac4e52c7944c29656a8 to your computer and use it in GitHub Desktop.
Clamp number between min and max
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 clamp(val, min, max) { | |
return Math.min(Math.max(min, val), max) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment