I need help updating nested array elements in JavaScript. I want to convert dates into a different format. How can I update the nested elements?
array1 = [
{
"week": [
"2019-05-06T16:00:00.000Z",
"2019-05-07T16:00:00.000Z",
"2019-05-08T16:00:00.000Z",
"2019-05-09T16:00:00.000Z",
"2019-05-10T16:00:00.000Z",
"2019-05-11T16:00:00.000Z",
"2019-05-12T16:00:00.000Z"
],
"weekNumber": 19
},
{
"week": [
"2019-05-20T16:00:00.000Z",
"2019-05-21T16:00:00.000Z",
"2019-05-22T16:00:00.000Z",
"2019-05-23T16:00:00.000Z",
"2019-05-24T16:00:00.000Z",
"2019-05-25T16:00:00.000Z",
"2019-05-26T16:00:00.000Z"
],
"weekNumber": 21
},
{
"week": [
"2019-06-03T16:00:00.000Z",
"2019-06-04T16:00:00.000Z",
"2019-06-05T16:00:00.000Z",
"2019-06-06T16:00:00.000Z",
"2019-06-07T16:00:00.000Z",
"2019-06-08T16:00:00.000Z",
"2019-06-09T16:00:00.000Z"
],
"weekNumber": 23
}
];
expectedResult = [
{
"week": [
"2019-05-06",
"2019-05-07",
"2019-05-08",
"2019-05-09",
"2019-05-10",
"2019-05-11",
"2019-05-12"
],
"weekNumber": 19
},
{
"week": [
"2019-05-20",
"2019-05-21",
"2019-05-22",
"2019-05-23",
"2019-05-24",
"2019-05-25",
"2019-05-26"
],
"weekNumber": 21
},
{
"week": [
"2019-06-03",
"2019-06-04",
"2019-06-05",
"2019-06-06",
"2019-06-07",
"2019-06-08",
"2019-06-09"
],
"weekNumber": 23
}
];
I want to remove ":00:00.000Z". I have a formatting function that removes that but I am unsure how to call it here.