Skip to content

Instantly share code, notes, and snippets.

@geraldyeo
Created December 27, 2016 05:48
Show Gist options
  • Save geraldyeo/14818564c14f2ac4e52c7944c29656a8 to your computer and use it in GitHub Desktop.
Save geraldyeo/14818564c14f2ac4e52c7944c29656a8 to your computer and use it in GitHub Desktop.
Clamp number between min and max
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