0

I have following part of code: I would like to create new Array of objects based on this arr but only with age and id property

const arr = [
  {
    name: "A",
    age: 1,
    id: 11,
  },
  {
    name: "B",
    age: 2,
    id: 22,
  },
  {
    name: "C",
    age: 3,
    id: 33,
  },
  {
    name: "D",
    age: 4,
    id: 44,
  },
];

1 Answers1

0

Thanks for your question Try this:

var newArr=arr.map(item=>{
return  {
    id:item.id,
    age :item.age
  } 
})
Aymen Ben Salah
  • 489
  • 4
  • 13