Last active
August 29, 2015 14:23
-
-
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.
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
/** | |
* 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