Powered By GitBook
SOME
Check if any item in a list matches

Description

Checks if there is at least one item in the given list that matches the given criteria. Returns true if a match was found, otherwise false.
The criteria is defined as a formula at the second parameter. The formula is evaluated with each item in the list. The formula must result in a true/false value. When the formula results in true, then the function will also return true.

Function signature

1
SOME(list: Array, selectionformula: Function) => Boolean
Copied!
Parameter
Description
List
List of items to search
Selection formula
Formula used to determine if an item matches the criteria

Examples

1
animals = [
2
{
3
"name": "dog",
4
"weight": 123
5
},
6
{
7
"name": "cat",
8
"weight": 48
9
},
10
{
11
"name": "rat",
12
"weight": 10
13
},
14
{
15
"name": "pig",
16
"weight": 230
17
}
18
]
19
products = [
20
{
21
"name": "Duct tape",
22
"category": "Utility"
23
},
24
{
25
"name": "Swiss army knife",
26
"category": "Tools"
27
},
28
{
29
"name": "Glue",
30
"category": "Utility"
31
}
32
]
Copied!
Formula
Return value
SOME(animals, item.name == "cat")
true
SOME(animals, item.name == "horse")
false
SOME(animals, item.weight > 100)
true
SOME<product>(products, product.category == "Utility")
true
SOME<product, position>(products, position == 1)
true
Last modified 10mo ago
Export as PDF
Copy link