Skip to content

Instantly share code, notes, and snippets.

@edgarberm
Created August 4, 2016 10:29
Show Gist options
  • Save edgarberm/0bb129bad9bdf72b38c983e66db8a8d1 to your computer and use it in GitHub Desktop.
Save edgarberm/0bb129bad9bdf72b38c983e66db8a8d1 to your computer and use it in GitHub Desktop.
Returns a number whose value is limited to the given range
clamp (n, min, max) {
return Math.max(Math.min(n, max), min)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment