Hello, I'm struggling with transforming this object into an array of objects.
The 'number' and 'reason' fields are currently stored as strings separated by commas. I need to split them into their own separate objects. The example dataset along with the desired output is shown in the code snippet below.
// Initial data structure
const data = {
date: "2021-09-07 10:28:34,2021-09-08 14:45:22",
startDate: "2021-09-07 00:00:00,2021-09-08 14:45:22"
id: "111111"
number: "1,9"
reason: "Autres,Autres"
}
// Expected output:
const res = [{
date: "2021-09-07 10:28:34",
startDate: "2021-09-07 00:00:00",
id: 11111,
number: 1,
reason: "Autres"
} {
date: "2021-09-08 14:45:22",
startDate: "2021-09-08 14:45:22",
id: 11111,
number: 9,
reason: "Autres"
}]