Created
November 13, 2023 17:38
-
-
Save avisek/ab3b026819e7079ba7798b27a5d5db0a to your computer and use it in GitHub Desktop.
Constrains a number between a minimum and maximum value.
This file contains hidden or 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 constrain(value, min, max) { | |
return Math.min(Math.max(value, min), max) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment