intersection() compares two arrays and returns a new array containing only the values they have in common.
Example:
Array 1 — Constituent Codes: Individual, Board Member
Array 2 — Specific List: Trustee, Board Member
Result: Board Member
I'm nesting intersection() inside length() so I can use the result directly in a Conditional Control to determine whether the constituent has any of the codes I'm looking for:
length(intersection(variables('SpecificList'), body('SelectConstCodes'))
If the result is greater than 0, there's a match.
This method is so much better than looping through one of the arrays to compare each current value against the other one.