I'm facing a challenge with an array of objects in the following structure:
[{
"X": "valueX",
"Y": "valueY",
"Z": "valueZ"
}, {
"X": "anotherX",
"Y": "anotherY",
"Z": "anotherZ"
}]
My goal is to transform this data into a two-dimensional array as shown here:
[["thisA","thisB","thisC"], ["thatA","thatB","thatC"]]
I am aware that we can achieve this using the map() function while specifying the keys (X, Y, Z).
newArray = dataArray.map(item => [item['X'], item['Y'], item['Z']])
However, I am looking for a more generic solution that would work regardless of the specific keys used in the array. Since the content and keys of the array may vary, is there a universal method to accomplish this transformation?