I have a function which is returning a js object in this format
{ _id: { day: 21, month: 10, year: 2020 },
  TOTAL: 9,
  A: 4,
  B: 1,
  C: 1,
  D: 2 }
and I have to format the above one into this format:
{ modalities:
   { TOTAL: { '21-09-2020': 2, '20-10-2020': 1, '21-10-2020': 8 },
     A: { '21-09-2020': 1, '21-10-2020': 4 },
     B: { '21-10-2020': 1 },
     C: { '21-09-2020': 1, '21-10-2020': 1 },
     D: { '20-10-2020': 1, '21-10-2020': 2 } } }
as a beginner, I don't have much experience with formatting and right now I'm thinking to implement this with forEach. Is there any better way to do it in javascript?
 
     
    