Range for warning message isn't working
I'm trying to get a range of 30 to 37, if it's between these numbers, I want no alert to show. If it's below or above I would like to display an alert. Here's my code that's not giving the alert the way I want.
if (slope <= 30 && slope >= 37) {
MyMessage;
}
Where am I going wrong here? Tried changing the <>
every way I can开发者_JS百科 think of, and not getting the desired outcome. Thanks for your help!
Use logical or instead of logical and:
if (slope <= 30 || slope >= 37) {
MyMessage;
}
You were asking if slope is <= 30 and >= 37. It can't be both. You want to ask if slope is <= 30 or >= 37, either one.
精彩评论