Skip to content

Instantly share code, notes, and snippets.

@chris5marsh
Created October 31, 2013 11:41
Show Gist options
  • Save chris5marsh/7248302 to your computer and use it in GitHub Desktop.
Save chris5marsh/7248302 to your computer and use it in GitHub Desktop.
Find out if a number is between two others
// Find out if number is between a and b
if (typeof(Number.prototype.isBetween) === "undefined") {
Number.prototype.isBetween = function(a, b) {
var max = Math.max(a,b),
min = Math.min(a,b);
return (this <= max) && (this >= min);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment