0

Let's say I got an array of objects like this:

let arrayOfObjects = [{Name: "A", Number: "1"} {Name: "A", Number: "2"} {Name: "B", Number: "2"} {Name: "A", Number: "2"}]

How can I loop through this, and add the unique values of "Number" to a new array? So the desired new array would be:

let newArray: [1,2]
0

1 Answer 1

0
let newArray = [...new Set(arrayOfObjects.map(el => parseInt(el.Number)))]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.