Compare Variables

Hi All,

Complete newbie to node red, so please excuse my basic question.

I have a variable I’m converting to a message.

If 0 == message 1
If < 20 message 2
If > 20 message 3

The problem I have is I don’t want to include 0 for message 2.
So message 2 need to be less than 20 but not = 0 or less than 20 but greater than 0?

Thanks in advance.

if (x == 0) {
   do something i.e. message1
} else if ( (x > 0) && (x < 20) ) {
   do something i.e. message2
} else {  // at this point x has to be 20 or more.
   do something i.e. message3
}  

something like this??

Thats perfect thank you it’s very much appreciated.

What if value is <0?

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.