pluckProperty
Given an array of objects and a property name, return a new array containing the value of that property from each object.
Examples
pluckProperty([{name: 'John'}, {name: 'Jane'}], 'name') → ['John', 'Jane']
pluckProperty([{value: 10}, {value: 20}], 'value') → [10, 20]
Starter code
function pluckProperty(arr, key) {
}
Complexity of the optimal solution
Time O(n), space O(n). The `map` method iterates over the 'n' objects in the array. It creates a new array of the same size to store the plucked values. Both time and space are linear.