I have an array of objects like this:
"addresses": [
    {
      "addressOrgName": "ACME",
      "addressLine1": "1 BRAIDWOOD AVENUE",
      "addressLine2": "KNUTSFORD",
      "county": "CHESHIRE",
      "postCode": "WA1 1QP",
      "country": "UNITED KINGDOM",
      "type": "DELIVERY",
      "telephoneNumber" : "0151234533"
    },
    {
      "addressOrgName": "ABC SUPPLIES",
      "addressLine1": "UNIT 4 MILLENNIUM BUSINESS ESTATE",
      "addressLine2": "BRUNTWOOD",
      "county": "DEVON",
      "postCode": "D1 5FG",
      "country": "UNITED KINGDOM",
      "type": "COLLECTION"
    },
    {
      "addressOrgName": "EFG ELECTRICAL",
      "addressLine1": "UNIT 4 MILLENNIUM BUSINESS ESTATE",
      "addressLine2": "BRUNTWOOD",
      "county": "DEVON",
      "postCode": "D1 5FG",
      "country": "UNITED KINGDOM",
      "type": "RETURN"
    }
  ]
One or two addresses type may not be present, but there will always be the one with type: DELIVERY. What I need to accomplish is to check if and which one are not there and push into the array the one(s) missing, so the resulting array will be like this:
"addresses": [
    {
      "addressOrgName": "ADDRESSEE ONLY",
      "addressLine1": "1 BRAIDWOOD AVENUE",
      "addressLine2": "KNUTSFORD",
      "county": "CHESHIRE",
      "postCode": "WA1 1QP",
      "country": "UNITED KINGDOM",
      "type": "DELIVERY",
      "telephoneNumber" : "0151234533"
    },
    {
      "addressOrgName": "",
      "addressLine1": "",
      "addressLine2": "",
      "county": "",
      "postCode": "",
      "country": "",
      "type": "COLLECTION"
    },
    {
      "addressOrgName": "",
      "addressLine1": "",
      "addressLine2": "",
      "county": "",
      "postCode": "",
      "country": "",
      "type": "RETURN"
    }
  ]
No idea how to approach it. Ideas?
Thank you
 
     
     
     
    