Skip to content

Instantly share code, notes, and snippets.

@Rycochet
Created January 24, 2014 13:39
Show Gist options
  • Save Rycochet/8597399 to your computer and use it in GitHub Desktop.
Save Rycochet/8597399 to your computer and use it in GitHub Desktop.
Make sure a number is within a minimum and maximum
/**
* 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