Hola, ¿cómo hago un bucle a través de una matriz en la que ya he hecho un bucle? Entonces busco el subarreglo y sigo teniendo el antiguo arreglo
array = [ { "DocNum": 210446, "DocType": "Test", "DocumentLines": [ { "LineNum": 0, "ItemCode": "427" }, { "LineNum": 0, "ItemCode": "34" } ] }, { "DocNum": 210446, "DocType": "Test", "DocumentLines": [ { "LineNum": 0, "ItemCode": "427" }, { "LineNum": 0, "ItemCode": "34" } ] } ] for (let element of array) { newArray.push({ key1: element.DocNum, key2: element.DocType, key3: element.DocumentLines[???].ItemCode })}Entonces la matriz se verá así al final
{ "key1":210446, "key2":Test, "key3": [{ItemCode: 34},{"ItemCode": 427}] }
Puede asignar los códigos de artículo
element.DocumentLines.map(v => v.ItemCode)Esto devolverá la matriz de ItemCodes de su primera matriz.