0

Say I have an array of objects:

[
  {
    'prop1': 'hello world',
    'prop2': false
  },
  {
    'prop1': 'asdf asdf',
    'prop2': true
  },
  {
    'prop1': 'bob ross',
    'prop2': false
  }
]

And now I want to create a new array that just lists one of the properties, for example:

createArrayFromProperties(array, item.prop1);

↓ Output ↓

['hello world', 'asdf asdf', 'bob ross']

Is this possible to do with a built in JS method, or do I have to use a loop?

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
Alex Wohlbruck
  • 1,340
  • 2
  • 25
  • 41

0 Answers0