Either || Conditional Operator Question

Im trying to get this code to evaluate to true for either a value of “F01” or “F02”, but instead the result is always false for both values.

However, if I remove the || relation !== “F02” portion, the value of “F01” evaluates true as expected.

Can someone help?

2 Likes

What do you get for…
let relation = itemData.relationSort;

Add the following log…
let relation = itemData.relationSort; console.log('VALUE: ', relation);

And now take a look onto your CONSOLE and check the output.

Your comparison is…

If VALUE is NOT —> ‘F1’ (STRING) …or… if VALUE is NOT —> ‘F02’ (STRING)

Of course VALUE should be also a STRING.

Result for ‘F3’ should be —> ??? —> yes —> TRUE → because is NOT F1 and is NOT F2

As soon one of the → is NOT <— has been hit —> TRUE

But wait, what if we do the same with → F1 ???

Is not F1 → false ok —> BUT —> isNot F2 —> W T F ??? → again TRUE ???

Ok one more time with F2…

Is not F1 → TRUE —> F U CK !!! → already → TRUE again ??? What the H E L L !!!

So, you recognize some error in the logic?

1 Like

Thank you for your input Russian-Dima. It pointed me in the right direction. Here are the changes I made to make it work properly.

1 Like

Don’t forget to mark it as → SOLUTION <— if you have found your → SOLUTION !