Removing duplicated key in array

Hello, I have some values in child array ( issued items ) and another child array ( returned items ). May i know if there is anyway i could remove duplicates items between these array and return only that is non duplicate in “issued items” array

The function below should do it:

const response = [];

for (const item of items) {
  const issuedItem = item.json['Issued Items'];
  const returnedItems = item.json['Returned Items']
  const toDeleteIndex = [];
  
  for (const returnedItem of returnedItems) {
    if (issuedItem.includes(returnedItem)) {
      toDeleteIndex.push(issuedItem.indexOf(returnedItem))
    }
  }
    
  for (const index of toDeleteIndex) {
     item.json['Issued Items'].splice(index, 1)
  }
  
  response.push(item)
}

return response
Example workflow
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      \"Issued Items\": [\n        \"1\",\n        \"2\"\n      ],\n      \"Returned Items\": [\n       '3',\n       '4',\n       '1',\n      ]\n    }\n  }\n]\n"
      },
      "name": "Set Example Data1",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        480,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const response = [];\n\nfor (const item of items) {\n  const issuedItem = item.json['Issued Items'];\n  const returnedItems = item.json['Returned Items']\n  const toDeleteIndex = [];\n  \n  for (const returnedItem of returnedItems) {\n    if (issuedItem.includes(returnedItem)) {\n      toDeleteIndex.push(issuedItem.indexOf(returnedItem))\n    }\n  }\n    \n  for (const index of toDeleteIndex) {\n     item.json['Issued Items'].splice(index, 1)\n  }\n  \n  response.push(item)\n}\n\nreturn response"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        700,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set Example Data1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Example Data1": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

@RicardoE105 thank you very much…it works very well. :grinning: