MAP function

The MAP function allows you the perform an action (function) over each element of an array resulting in a new array with the mapped values.

Syntax

The syntax for MAP is as follows

FS
MAP(array, f)
  • array an array (collection/list) of values
  • f the function you want to apply on each value (can be built-in or a custom function)

The result is another array

Examples

FS
// Make every string in the array uppercase MAP(ARRAY("alice", "bob", "chris"), UPPERCASE) // -> ["ALICE", "BOB", "CHRIS"] // Square every number in the array MAP(ARRAY(1, 2, 3, 4, 5), function(x: x ^ 2)) // -> [1, 4, 9, 16, 25]

Related articles

Learn more about map in one of the following articles