Powered By GitBook
FIND
Finds an item from list

Description

Finds the first item from the given list that matches the given criteria. Returns that item, or null if not found.
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. If true, then item will be included to the result, otherwise it will be excluded.

Function signature

1
FIND(list: Array, selectionformula: Function) => Object|Undefined
Copied!
Parameter
Description
List
List of items to search
Selection formula
Formula used to determine if an item is the one to find from the list

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
FIND(animals, item.name == "cat")
{"name":"cat","weight":48}
FIND(animals, item.name == "horse")
undefined
FIND(animals, index == 2)
{"name":"rat","weight":10}
FIND<product>(products, product.name == "Duct tape")
{"name":"Duct tape","category":"Utility"}
FIND<product, position>(products, position == 1)
{"name":"Swiss army knife","category":"Tools"}
Last modified 10mo ago
Export as PDF
Copy link