Skip to content

Instantly share code, notes, and snippets.

@avisek
Created November 13, 2023 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avisek/ab3b026819e7079ba7798b27a5d5db0a to your computer and use it in GitHub Desktop.
Save avisek/ab3b026819e7079ba7798b27a5d5db0a to your computer and use it in GitHub Desktop.
Constrains a number between a minimum and maximum value.
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