title: How to update array of objects that includes the array of objects in array
body: <pre><code>const example = [
    {
      group: 'Group1',
      subcategories: 
      [
        {
          label: 'Example1',
          content: 'Example1'
        },
        {
          label: 'Example2',
          content: 'Example2'
        },
        {
          label: 'Example3',
          content: 'Example3'
        },
      ]
    },
    {
      group: 'Group2',
      subcategories: 
      [
        {
          label: 'Example1',
          content: 'Example1'
        },
        {
          label: 'Example2',
          content: 'Example2'
        },
        {
          label: 'Example3',
          content: 'Example3'
        },
        {
          label: 'Example4',
          content: 'Example4'
        },
        {
          label: 'Example5',
          content: 'Example5'
        },
        {
          label: 'Example6',
          content: 'Example6'
        },
        {
          label: 'Example7',
          content: 'Example7'
        },
      ]
    },
    {
      group: 'Group3',
      subcategories: 
      [
        [
          {
            label: 'Example1',
            content: 'Example1'
          },
          {
            label: 'Example2',
            content: 'Example2'
          },
          {
            label: 'Example3',
            content: 'Example3'
          },
        ]
      ]
    },
    {
      group: 'Group4',
      subcategories: 
      [
        {
          label: 'Example1',
          content: 'Example1'
        },
        {
          label: 'Example1',
          content: 'Example1'
        },
        {
          label: 'Example1',
          content: 'Example1'
        },
      ]
    },
  ]
  
  const infogroup = 'Group3';
  const infogroupLabel = 'Example2'
  const updatedValue = 'updated'
  
  const updated = example.map((group, index) =&gt; {
      if (group.group === infogroup) {
          return {
              ...group,
              subcategories: group.subcategories.map((subgroup, index) =&gt; {
                  if (Array.isArray(subgroup)) {
                      const updatedMetaInfoField = subgroup.map((field, index) =&gt; {
                          if (field.label === infogroupLabel) {
                              return { ...field, content: updatedValue };
                          }
                          return field;
                      });
                      return [...updatedMetaInfoField];
                  }
                  return {
                      ...subgroup,
                      content: subgroup.label === infogroupLabel ? updatedValue : subgroup.content,
                  };
              }),
          };
      }
      return group;
  });
  </code></pre>
  <p>Hi everyone, can someone help me to update this array of objects in an immutable way? The issue is with the Group3 that has Array in Array. Other groups work fine. Also this array of objects can have the same label and content values as you can see in the Group4.</p>
  <p>I tried on my own to create the method called &quot;updated&quot; but when I want to update the Group3, it is not working as expected.</p>
  <p>Thank you very much for your help.</p>
  <pre><code>interface Group {
      content: string
      label: string
  }
  
  interface GroupInfo {
      group: string
      subcategories: Group[] | Group[][]
  }
  </code></pre>