Created
January 31, 2022 05:19
-
-
Save queviva/fd5655796e34e654fbf777d8d4f65d5d to your computer and use it in GitHub Desktop.
method that quickly tells you if a value, x, is between any two other unknown values, y and z
This file contains hidden or 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
const XbetweenYandZ = (x, y, z) => (x-y) * (x-z) < 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this method tells you whether an unknown value is mathematically 'between' two other unknown values - it is not required to know if y is greater or less than z
you call it by passing in the value to check, then the two other values