Kevin Powell - CommunityKP-C
Kevin Powell - Community4y ago
13 replies
MC23

Unwanted undefined key in object

Starting from an array like this:
    gridColumns =
    [
      { field: "exam_Internalcode", title: 'Exam ID' },
      { field: "patient", title: 'Patient Name' },
  ]
And an array like this
  gridData = [
    { exam_Internalcode: 'I-12M4', patient: 'Mark Lenner', idblock: 125 },
    ...
  ]
What's the best way to obtain an array like this?
result = [
  {'Exam ID': 'I-12M4', 'Patient Name': 'Mark Lenner'} //no idblock because there is no field for it in gridColumns 
  ...
]
Current solution https://jsfiddle.net/n00bCod3r/jdc1hu5p/

However, I get an undefined key and I don't understand why
Was this page helpful?