Using MAP or flatMap in Node

Does someone can inform how I can use map or flatmap into Function Node?

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        330,
        330
      ]
    },
    {
      "parameters": {
        "functionCode": "return [{\n  json: {\n      \"code\":886079657,\n      \"codinterger\":\"1377\",\n      \"fullname\":\"ACME\",\n      \"tags\":[\n         {\"tag\":\"Supplier\"},\n         {\"tag\":\"testA\" },\n         {\"tag\":\"testB\" },\n         {\"tag\":\"testC\" }\n      ],\n      \"type\":\"N\"\n  }\n}];\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        530,
        330
      ]
    },
    {
      "parameters": {
        "functionCode": "let onlyTags = $node[\"Function\"].json[\"tags\"].flatMap(f => f.tags.map(t => `\"value\": ${t.tag}`));\n\nreturn [{\n  json: {\n    \"postal_codes\": onlyTags \n  }\n}]\n"
      },
      "name": "Map",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        730,
        330
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Map",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

If I understood correctly you want to map this:

{
  "code": 886079657,
  "codinterger": "1377",
  "fullname": "ACME",
  "tags": [
    {
      "tag": "Supplier"
    },
    {
      "tag": "testA"
    },
    {
      "tag": "testB"
    },
    {
      "tag": "testC"
    }
  ],
  "type": "N"
}

To this:

{
   "tags": ["Supplier", "testA", ....]
}

If that is the case, you can use the Item Lists node. Check the example below.

Example workflow
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        0,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return [{\n  json: {\n      \"code\":886079657,\n      \"codinterger\":\"1377\",\n      \"fullname\":\"ACME\",\n      \"tags\":[\n         {\"tag\":\"Supplier\"},\n         {\"tag\":\"testA\" },\n         {\"tag\":\"testB\" },\n         {\"tag\":\"testC\" }\n      ],\n      \"type\":\"N\"\n  }\n}];\n"
      },
      "name": "Function1",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        -300,
        530
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "tags",
        "options": {}
      },
      "name": "Item Lists",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        -40,
        530
      ]
    },
    {
      "parameters": {
        "operation": "aggregateItems",
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "tag",
              "renameField": true,
              "outputFieldName": "tags"
            }
          ]
        },
        "options": {}
      },
      "name": "Item Lists1",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        230,
        530
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Function1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function1": {
      "main": [
        [
          {
            "node": "Item Lists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists": {
      "main": [
        [
          {
            "node": "Item Lists1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Hi @RicardoE105 ,
almost it, it you see in my code, then you will notice that I need to insert a increment in the result:

"value": ${t.tag}

An index? I ran you code a got:

To do that, add the following code to Map2

const tags = items[0].json.tags;
return [
  {
    json: {
      tags: tags.map(tag => `value: ${tag.tag}`)
    } 
  }
]

@RicardoE105 , your solution worked very well. Thank you.
If you allow me, let me ask you one more thing, how many ways is possible to select a Node, for instance:

items[0].json.tags // select from the current node
$node["Function"].json["tags"] // select from a specific node
items[0].json.app_key
$item(0).$node["Init Data"].data["myNumber"];
$items("Webhook_Start", 0, 0)[0].json.body
$items("HTTP Request", 0, counter)
$node["getPOSTCODE_API_A"].json["status"]