Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

97
Views
ForEach dentro de Foreach Javascript

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}] }

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede asignar los códigos de artículo

 element.DocumentLines.map(v => v.ItemCode)

Esto devolverá la matriz de ItemCodes de su primera matriz.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!