Here is the JSON object I am working with:
{
"id": 2,
"service": "mobile",
"min": "20",
"per": "10",
"tax": "1",
"categoryservices": [
{
"category": {
"id": 1,
"name": "laptop"
}
},
{
"category": {
"id": 2,
"name": "software"
}
}
]
}
I aim to transform the output as follows:
{
"id": 2,
"service": "mobile",
"min": "20",
"per": "10",
"tax": "1",
"cats": [1,2] //the numbers represent ids from categoryservices array inside the category object
}
I am seeking guidance on how to achieve this using the map function in JavaScript. As a newcomer to JavaScript, should I use map or a for loop approach?