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

Example 1: Capitalize values in a collection

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:

MAP(FN(x,UPPER(x)), data.fleet_names)

This returns the following:

["BMW, "AUDI", "MERCEDES BENZ"]