I have a collection of objects, each with a unique NAME property. However, there are duplicates in the collection where some objects share the same NAME.
const arr = [
{name: "x", place: "a", age: "13" },
{name: "x", place: "b", age: "14" },
{name: "y", place: "c", age: "15" },
{name: "d", place: "d", age: "16" }
]
Is there a way to filter this collection so that only one object remains per unique NAME? Any duplicates should be removed from the list.
The desired output should look like:
const arr = [
{name: "x", place: "a", age: "13" },
{name: "y", place: "c", age: "15" },
{name: "d", place: "d", age: "16" }
]
or
const arr = [
{name: "x", place: "b", age: "14" },
{name: "y", place: "c", age: "15" },
{name: "d", place: "d", age: "16" }
]
Can Lodash be utilized for this task?