Skip to content

Instantly share code, notes, and snippets.

@jens1101
Created June 5, 2023 07:37
Show Gist options
  • Save jens1101/9890f8e5a9f49db198199c0ec28c215d to your computer and use it in GitHub Desktop.
Save jens1101/9890f8e5a9f49db198199c0ec28c215d to your computer and use it in GitHub Desktop.
How to clamp numbers in JS
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment