HI and sorry

I need again help to figure out a maybe syntax problem

if( a=="1" || b=="10" || c=="100"){ ......... working,

if( (a=="1" || b=="10" || c=="100") && d >1000){ ........is not working.

do I have a bracket problem?

THX

HI and sorry

I need again help to figure out a maybe syntax problem

if( a=="1" || b=="10" || c=="100"){ ......... working,

if( (a=="1" || b=="10" || c=="100") && d >1000){ ........is not working.

do I have a bracket problem?

THX

does changing it to (d>1000) do anything?

Is a,b,c and d a string or an number?

With **a=="1"** you a comparing a string, not a number.

**d >1000** can only works with a number.

Maybe you can show where the values are coming from and what type variable they are.

`if( (a==1 || b==10 || c==100) && d > 1000){`

this works if all your variable are number

@ edje11

a, b c are strings coming von mqtt,

d is a counter so it is a number

@cymplecy

no no change, not working

This code works fine:

```
let a="2";
let b="3";
let c="100";
let d=1001;
if( (a=="1" || b=="10" || c=="100") && d >1000){
msg.payload = "OK";
return msg;
}
```

If you then change to this, you won't see ok in the debug so this code is working

```
let a="2";
let b="3";
let c="100";
let d=1000;
if( (a=="1" || b=="10" || c=="100") && d >1000){
msg.payload = "OK";
return msg;
}
```

To be sure, stick this into your function.

```
node.warn("a is "+typeof a +", b is "+typeof b +", c is "+typeof c +", d is "+typeof d)
```

Thanks for the tip with node.warn. My if syntax is correct only a value is a number instead of a string. So I have two strings and two numbers. With this knowledge my function is running and learned something new again!

THX

1 Like

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