0

I've array like this

const data=[ {name:aa, status:[key:0, value: true] },
         {name:ee, status:[key:1, value: true] },
         {name:ii, status:[key:1, value: true] },
       ]

I want to convert it into like this

const data=[aa, ee, ii]

P.S. thank you.


tried like this

data.map(({ status, ...data }) => Object.values(data).concat);

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140

1 Answers1

3

Assuming you have an array of objects, you need to take name from the object probably by destructuring and map this value.

const
    data = [{ name: 'aa', status: { key: 0, value: true } }, { name: 'ee', status: { key: 1, value: true } }, { name: 'ii', status: { key: 1, value: true } }],
    result = data.map(({ name }) => name);

console.log(result);
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392