MAP
Transforms each item in the list to another

Description

Goes through each item in the given list and evaluates an formula for each of them. Returns a list with the evaluated values.
The returned list has the same length than the original list, and the order of its items correspond the order in the original list.

Function signature

1
MAP(list: Array, transformformula: Function) => Array
Copied!
Parameter
Description
List
List of items to transform
Transform formula
Formula to be evaluated for each item

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
products = [{"name":"Duct tape","price":5},{"name":"Swiss army knife","price":60}]
Copied!
Formula
Return value
MAP(animals, item.name)
["dog","cat","rat"]
MAP(products, index + ": " + item.name)
["0: Duct tape","1: Swiss army knife"]
MAP<product>(products, product.name + " (" + product.price + "€)")
["Duct tape (5€)","Swiss army knife (60€)"]
MAP<product, position>(products, position + ": " + product.name + " (" + product.price + "€)")
["0: Duct tape (5€)","1: Swiss army knife (60€)"]
Last modified 1yr ago
Export as PDF
Copy link