I’m new in JS… can someone help me to change this:
JavaScript
x
1
1
arr = [{type:'fruit', name:'apple', color:'red'},{type:'fruit', name:'banana', color:'yellow'}]
to this:
JavaScript
1
1
1
arr = [['fruit', 'apple', 'red'],['fruit', 'banana', 'yellow']]
Advertisement
Answer
You can map your array using Object.values()
as a callback:
JavaScript
1
2
1
arr = arr.map(Object.values);
2