As the title states, I am trying to return an array containing the value associated with that key for each object, or undefined if that key is not present.
Here is what I have so far:
function pluck(arr, name) {
permittedValues = arr.map(function(value) {
return value.key || undefined;
});
}
console.log(
pluck([
{ name: "Tim" }, { name: "Matt" }, { name: "Elie" }],
'name'
)
);
I am trying to return something like this:
// ["Tim", "Matt", "Elie"]