PLUCK

Get a property of each object in a list

Description

Gets the values for each object in the given list by the given key, and returns a list with those values, in the corresponding order.

For example, if you have a list of people as objects, you can get the name of each person by providing the list as the first parameter, and the key name "name" as the second parameter.

Function signature

PLUCK(list: Array, key: String) => Array

Parameter

Description

List

List of objects whose properties to get

Key

Name of the key whose value to take from each object

Examples

products = [{"name":"Duct tape","price":5},{"name":"Swiss army knife","price":60}]
animals = [
{
"name": "dog",
"weight": 123
},
{
"name": "cat",
"weight": 48
},
{
"name": "rat",
"weight": 10
}
]

Formula

Return value

PLUCK(products, "price")

[5,60]

PLUCK(animals, "name")

["dog","cat","rat"]