Created
November 15, 2022 08:01
-
-
Save elpddev/9b6b20828abcefaacdde368758841b9f to your computer and use it in GitHub Desktop.
Clamp number to a range. If below min then min, If above max then max
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const clamp = (min: number, max: number, val: number) => | |
Math.max(min, Math.min(val, max)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment