MAP

MAP applies a function to every element in a collection and returns an array.

Function category: Collection

Syntax

MAP(arg1, arg2)

Arguments

Description

arg1

Function to be applied to the collection.

arg2

A collection.

Examples

Let's say we're given a response with the following vehicle information:

{
"data": {
"fleet_prices": [
16000,
17450,
9200
],
"fleet_names": [
"bmw",
"audi",
"mercedes benz"
]
}
}

If we want all of the values in fleet_names to be capitalized, we can use MAP with the UPPER function.

# Capitalize values in a collection
MAP(FN(x,UPPER(x)), data.fleet_names)
# Returns ["BMW, "AUDI", "MERCEDES BENZ"]