Condition comparison with a list of values

Hi everyone,
I’m trying to set the visibility of an icon based on a item state, in particular I would like the condition to be satisfied when the item’s value matches with one of the list s values.
I tried with this code but it doesn’t work.
some advice ?

visible: "=items[props.Current_condition].state === ['801', '500', '604'] ? true : false"

There’s a bunch off with this line but I think we can get there from here.

First review the expressions section in the docs.

In particular pay attention to the link to docs on the ternary operator. You have it mostly right but you are missing the parens around the condition. Though because you are after a boolean anyway, you don’t even need the ternary.

Next, while the full range of what you can do with JavaScript is not available in expressions, it’s still JavaScript. So search Google or your search engine of choice for something like “JavaScript how to see if a list has an element” and you should find something that points to Array.includes().

=['801', '500', '604'].includes(items[props.Current_condition].state)

You might need parens around it. I am not super fluent in JS and am not well versed when the parens are needed to evaluate or not.

=(['801', '500', '604'].includes(items[props.Current_condition].state))

thank you so much it works without parens:

=['801', '500', '604'].includes(items[props.Current_condition].state)

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