开发者

Range for warning message isn't working

开发者 https://www.devze.com 2023-03-14 01:12 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号