Skip to content

Instantly share code, notes, and snippets.

@queviva
Created January 31, 2022 05:19
Show Gist options
  • Save queviva/fd5655796e34e654fbf777d8d4f65d5d to your computer and use it in GitHub Desktop.
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
const XbetweenYandZ = (x, y, z) => (x-y) * (x-z) < 0;
@queviva
Copy link
Author

queviva commented Jan 31, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment