Created
January 24, 2014 13:39
-
-
Save Rycochet/8597399 to your computer and use it in GitHub Desktop.
Make sure a number is within a minimum and maximum
This file contains 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
/** | |
* Make sure a number is within a minimum and maximum | |
* @param {number} min | |
* @param {number} num | |
* @param {number} max | |
* @returns {number} | |
*/ | |
Math.range = function(min, num, max) { | |
return Math.max(min, Math.min(num, max)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment