Formatting data in array with objects
Do you really anticipate the data model changing so much that this needs to be ultra flexible?  In order to do so the code is quite complex - for instance having a forEach inside of an if inside of a forEach inside of a map.  You already have model specific checks in the code anyways, such as the check for the 'sickLeave' and 'holidayLeave' keys.  I think a solution along these lines would be perfectly acceptable:



const initialNormalizedVals = {
  "sickLeaveDifferance": [],
  "sickLeaveRevision": [],
  "sickLeavePaid": [],
  "holidayLeaveDifferance": [],
  "holidayLeaveRevision": [],
  "holidayLeavePaid": [],
  "received": [],
  "taken": [],
  "result": [],
}

const normalizedData = data.periods.reduce((outcome, { sickLeave, holidayLeave, received, taken, result }) =&gt; {
  outcome.sickLeaveDifferance.push(sickLeave.differance)
  outcome.sickLeaveRevision.push(sickLeave.revision)
  outcome.sickLeavePaid.push(sickLeave.paid)
  outcome.holidayLeaveDifferance.push(holidayLeave.differance)
  outcome.holidayLeaveRevision.push(holidayLeave.revision)
  outcome.holidayLeavePaid.push(holidayLeave.paid)
  outcome.result.push(result)
  outcome.taken.push(taken)
  outcome.received.push(received)

  return outcome
}, initialNormalizedVals)

const transformedData = Object.keys(normalizedData).map(key =&gt; {
  return {
    name: key,
    result: normalizedData[key],
  }
})