ES6 - Create new object from existing data, using only one property, and removing any duplicates?

N

Nick

Guest
I have an array of objects being returned to me as data, I'm looking to Create a new set of data, while retaining the old one for future use.

I'm trying to loop through the data given to create a new set of data that only contains age, but also removes any duplicates. I'm not too sure where to start with this.

data = [
{
"firstName": "John",
"lastName": "Doe",
"age": "99"
},
{
"firstName": "Jimmy",
"lastName": "Hendricks",
"age": "50"
},
{
"firstName": "William",
"lastName": "Shakespeare",
"age": "22"
},
{
"firstName": "Jane",
"lastName": "Eyre",
"age": "50"
}
]


What I'd like to end up with is something like this:

newData = [
{"age": "99"},
{"age": "50"},
{"age": "22"}
]

Continue reading...
 
Top