i have an array of objects in
[
{
"country": "USA",
"payment": [
{
"paymentType": "Visa",
"count": 1000
},
{
"paymentType": "MasterCard",
"count": 1000
}
]
},
{
"country": "CANADA",
"payment": [
{
"paymentType": "Visa",
"count": 1000
},
{
"paymentType": "MasterCard",
"count": 1000
}
]
},
{...}
]
I want to transform it into
[
["USA" , "VISA" , 10000 ],
["USA","Mastercard",1000],
[countryName2, paymentType,count] , ...
]
Can someone help me>?
I tried doing :
const data2 = data.map(function(elem) {
return [
elem.country,
elem.payment.map(b=> b.paymentType),
elem.payment.map(c=>c.count),
]
})
but the output i get is not what i want, if someone could show how to do it,
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)