• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

68
Vistas
Loop over complex array structures with best practice and lowest complexity

I am calling an API that returns

 [{
        Id:string,
        Value:string,
        Value2: 
          [{Id:string,Value3:string}] ,
 {
        Id:string,
        Value:string,
        Value2: 
          [{Id:string,Value3:string}] 
 }]

How do i loop over value 2 with lowest complexity and best approach in JS

almost 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I am not sure i understand your issue but you can simply map over your table items like that (assuming a variable called table holds your data):

table.map((item) => {
  console.log(JSON.stringify(item.Value2))
})

And if you want to loop over the values of Value2:

table.map((item) => {
  item.Value2.map((subitem) => {
    console.log(subitem.Value3)
  })
})
almost 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda