How to add an empty string key-value pair for dynamic keys in JavaScript? [closed]

I have an array of objects in JavaScript, where each object has dynamic keys with a specific format. The keys start with “dummy_bdr_”, “dummy_cushion_”, or “dummy_hurlde_”, followed by a unique string ending. Some of the objects may have a value for a particular key, while others may not.

I want to compare all three types of keys and add an empty string key-value pair for the missing keys with the same unique string ending as the object that has a value for that particular key. For example, if I have a value for “dummy_hurlde_W”, I want to add an empty string key-value pair for “dummy_bdr_W” and “dummy_cushion_W”.

Here’s an example of my data:

let diagnosticsResultsData = [
  {
    "Scenario": 1,
    "cf_id_lookup": 1,
    "detailed_bdr_A-1": 0.5588,
    "detailed_bdr_A-2": 0.5588,
    "detailed_bdr_B": 0.5671,
    "detailed_bdr_C": 0.5618333333333333,
    "detailed_cushion_A-1": -0.09126719517085935,
    "detailed_cushion_A-2": -0.09126719517085935,
    "detailed_cushion_B": -0.00493665941064092,
    "detailed_cushion_C": 0.037584659863863945,
    "detailed_hurlde_A-1": 0.6500671951708593,
    "detailed_hurlde_A-2": 0.6500671951708593,
    "detailed_hurlde_B": 0.572036659410641,
    "detailed_hurlde_C": 0.5242486734694694,
    "detailed_hurlde_D": 0.4595038342810658,
    "detailed_hurlde_E": 0.38444789399971846,
    "detailed_hurlde_W": 0.3116524809596418
  },
  {
    "Scenario": 2,
    "cf_id_lookup": 2,
    "detailed_bdr_A-1": 0.7867,
    "detailed_bdr_A-2": 0.7867,
    "detailed_bdr_B": 0.8042666666666666,
    "detailed_bdr_C": 0.7926333333333334,
    "detailed_cushion_A-1": 0.13663280482914064,
    "detailed_cushion_A-2": 0.13663280482914064,
    "detailed_cushion_B": 0.2322300072560256,
    "detailed_cushion_C": 0.26838465986386406,
    "detailed_hurlde_A-1": 0.6500671951708593,
    "detailed_hurlde_A-2": 0.6500671951708593,
    "detailed_hurlde_B": 0.572036659410641,
    "detailed_hurlde_C": 0.5242486734694694,
    "detailed_hurlde_D": 0.4595038342810658,
    "detailed_hurlde_E": 0.38444789399971846,
    "detailed_hurlde_W": 0.3116524809596418
  }
];

This is the desired Ouput

[
  {
    "Scenario": 1,
    "cf_id_lookup": 1,
    "dummy_bdr_A-1": 0.5588,
    "dummy_bdr_A-2": 0.5588,
    "dummy_bdr_B": 0.5671,
    "dummy_bdr_C": 0.5618333333333333,
    "dummy_bdr_D": "",
    "dummy_bdr_E": "",
    "dummy_bdr_W": "",
    "dummy_cushion_A-1": -0.09126719517085935,
    "dummy_cushion_A-2": -0.09126719517085935,
    "dummy_cushion_B": -0.00493665941064092,
    "dummy_cushion_C": 0.037584659863863945,
    "dummy_cushion_D": "",
    "dummy_cushion_E": "",
    "dummy_cushion_W": "",
    "dummy_hurlde_A-1": 0.6500671951708593,
    "dummy_hurlde_A-2": 0.6500671951708593,
    "dummy_hurlde_B": 0.572036659410641,
    "dummy_hurlde_C": 0.5242486734694694,
    "dummy_hurlde_D": 0.4595038342810658,
    "dummy_hurlde_E": 0.38444789399971846,
    "dummy_hurlde_W": 0.3116524809596418
  },
  {
    "Scenario": 2,
    "cf_id_lookup": 2,
    "dummy_bdr_A-1": 0.7867,
    "dummy_bdr_A-2": 0.7867,
    "dummy_bdr_B": 0.8042666666666666,
    "dummy_bdr_C": 0.7926333333333334,
    "dummy_bdr_D": "",
    "dummy_bdr_E": "",
    "dummy_bdr_W": "",
    "dummy_cushion_A-1": 0.13663280482914064,
    "dummy_cushion_A-2": 0.13663280482914064,
    "dummy_cushion_B": 0.2322300072560256,
    "dummy_cushion_C": 0.26838465986386406,
    "dummy_cushion_D": "",
    "dummy_cushion_E": "",
    "dummy_cushion_W": "",
    "dummy_hurlde_A-1": 0.6500671951708593,
    "dummy_hurlde_A-2": 0.6500671951708593,
    "dummy_hurlde_B": 0.572036659410641,
    "dummy_hurlde_C": 0.5242486734694694,
    "dummy_hurlde_D": 0.4595038342810658,
    "dummy_hurlde_E": 0.38444789399971846,
    "dummy_hurlde_W": 0.3116524809596418
  }
]