Problem with OR expressions


#1

Can someone fix this expression for some reason it’s not working
$currentEventValue == “open” || “active” ? “There is a device [red|$currentEventValue]” : “All devices are [green|SECURE]”


#2

Try

($currentEventValue == "open" || "active") ? "There is a device [red|$currentEventValue]" : "All devices are [green|SECURE]"

instead (operator precedence).


#3

Doesn’t this need to be entirely wrapped in parenthesis?


#4

|| is a logical operator (logical or), the result of “open” || “active” will give true. You need to use two comparisons with || in between them.


#5

Oops - my bad. Here’s what should be correct:

(($currentEventValue == "open") || ($currentEventValue == "active")) ? "There is a device [red|$currentEventValue]" : "All devices are [green|SECURE]"