Skip to content

Instantly share code, notes, and snippets.

@dutchcelt
Created December 7, 2023 16:17
Show Gist options
  • Select an option

  • Save dutchcelt/b3807dc41a17094ad56ff5a047da4e02 to your computer and use it in GitHub Desktop.

Select an option

Save dutchcelt/b3807dc41a17094ad56ff5a047da4e02 to your computer and use it in GitHub Desktop.
Clamp number
/**
* clamp
* @param {number} num
* @param {number} min
* @param {number} max
* @returns {number}
*/
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