(first stackoverflow post) This is a javaScript question, but I think the logic applies anywhere
I've wondered for a long time about using an if statement to compare multiple values against the same variable without needing to type out the variable every time; specifically, in regards to "greater than" and "less than".
The specific example I'm trying to solve is:
var middle = 5;
if(middle < 10 && middle > 0) {
//some stuff
}
I'm looking for something like:
var middle = 5;
if(middle (< 10 && > 0)) {
//the same stuff
}
I have checked is-there-a-way-to-shorten-the-condition-if-it-always-compares-to-the-same-thing and if-statements-matching-multiple-values and if-statement-multiple-conditions-same-statement. I could not derive a simple answer to my specific question from those.
A final note: I do not want to make a new "multiple if" function that accepts arguments and then compares them for the variable. I am looking for a "built-in" way to do this.
Thanks, -Charles