Sobes.tech
Junior — Senior

Retrieving object field values by a specified key

livecode

Task condition

Create a function that takes an array of objects and a string key, which returns a new array where each element contains only the property corresponding to the given key.

// ([{label: "label1", id: 1}], "label") => [{label: "label1"}]
// ([{label: "label1", id: 1}], "id") => [{id: 1}]