Skip to content

Instantly share code, notes, and snippets.

@WillSquire
Last active August 29, 2015 14:23
Show Gist options
  • Save WillSquire/a616774f157890bfbe64 to your computer and use it in GitHub Desktop.
Save WillSquire/a616774f157890bfbe64 to your computer and use it in GitHub Desktop.
In Range - See if the value is in the range of a and b.
/**
* Checks if a value is in the range (inbetween) the
* value of a and b. Will also return true if equal to
* either value.
*
* @param {number} value
* @param {number} a
* @param {number} b
* @returns {boolean}
*/
function inRange(value, a, b) {
if (a < b)
return (value >= a && value <= b);
return (value >= b && value <= a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment