IsValueInArray

Indicates whether a given value is a member of given array

javascript · Common Scripts

Source

var array = args.array;
var value = args.value;

if (!array || !value) {
  return 'no';
}

if (typeof array === 'string') {
    try {
        array = JSON.parse(array);
    } catch(e) {
        return (array === value) ? 'yes' : 'no';
    }
}

if (!Array.isArray(array)) {
  return (array === value) ? 'yes' : 'no';
}

var res = 'no';
value = value.toString();
array.forEach(function(item) {
  if (item.toString() === value) {
      res = 'yes';
  }
});

return res;

README

Indicates whether a given value is a member of given array.

Script Data


Name Description
Script Type javascript
Tags Condition

Inputs


Argument Name Description
array The array to look for the value.
value The value to look for in the array.

Outputs


Path Description Type
yes The list that contains the value. Unknown
no The list does not contain the value. Unknown