REJECT

Returns an array or object containing the items for which the given lambda is not true or are not contained within the values_to_remove array.

Syntax 

REJECT(array | object, values_to_remove | LAMBDA(item, [expr]))

Examples 

Example 1

Input

{
  "my_array": [
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9,
    10
  ]
}

Formula

REJECT(my_array, ARRAY(2, 4, 6, 8, 10))

Output

[
  1,
  3,
  5,
  7,
  9
]
Example 2

Input

{
  "my_array": [
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9,
    10
  ]
}

Formula

REJECT(my_array, LAMBDA(item, item > 5))

Output

[
  1,
  2,
  3,
  4,
  5
]
Example 3

Input

{
  "my_object": {
    "a": 1,
    "b": 2,
    "c": 3,
    "d": 4,
    "e": 5
  }
}

Formula

REJECT(my_object, ARRAY(2, 4))

Output

{
  "a": 1,
  "c": 3,
  "e": 5
}
Example 4

Input

{
  "my_object": {
    "a": 1,
    "b": 2,
    "c": 3,
    "d": 4,
    "e": 5
  }
}

Formula

REJECT(my_object, LAMBDA(item, item > 2))

Output

{
  "a": 1,
  "b": 2
}
Was this helpful?