1

I'm new in JS... can someone help me to change this:

arr = [{type:'fruit', name:'apple', color:'red'},{type:'fruit', name:'banana', color:'yellow'}]

to this:

arr = [['fruit', 'apple', 'red'],['fruit', 'banana', 'yellow']]
Viktor
  • 13
  • 3
  • Does this answer your question? [From an array of objects, extract value of a property as array](https://stackoverflow.com/questions/19590865/from-an-array-of-objects-extract-value-of-a-property-as-array) – Kinglish Oct 04 '22 at 17:09

1 Answers1

4

You can map your array using Object.values() as a callback:

arr = arr.map(Object.values);
Robo Robok
  • 21,132
  • 17
  • 68
  • 126