A = [{"name":"John","age":30,"city":"New York"},{"name":"Jimmy","age":40,"city":"Toronto"}]
B = [["John", 30, "New York"], ["Jimmy", 40, "Toronto"]]
How to convert A into B in JavaScript?
Thanks in advance for your help!
A = [{"name":"John","age":30,"city":"New York"},{"name":"Jimmy","age":40,"city":"Toronto"}]
B = [["John", 30, "New York"], ["Jimmy", 40, "Toronto"]]
How to convert A into B in JavaScript?
Thanks in advance for your help!
2
Answers
const A = [{"name":"John","age":30,"city":"New York"},{"name":"Jimmy","age":40,"city":"Toronto"}];
const B = A.map(item => [item.name, item.age, item.city]);
console.log(B);
simply: