Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

101
Vistas
How to navigate through all the values of an array of object

I'm trying to make a function that will get every key "quantidade", take their values, and multiply for the corresponding "tecnologia" key of the parent key, if the object has the "A" key in "tecnologia", it will multiply for the "A" value in the first object, this is what i did so far:

function calcula (tabela, arvore) {
    for (i = 0; i < arvore.length; i++) {
        arrFilhos = [`["filhos"][x]`]
        arrArvore = [`arvore[i]`]
        arrLevel = []

        for(x = 0; x < arvore[i]["filhos"].length; x++){
            if ("filhos" in eval(arrArvore[0])){
                console.log(eval(arrArvore.toString().replace(/,/g , "")))
                arrArvore.push(arrFilhos[0])
            }
        }
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I'm assuming that tecnologia only exists in the last node

function calculaCusto (tabelaCusto, arvoreArquitetura) {
   const cb = (prev, next) => {
     if(next.tecnologia) {
       return prev + next.quantidade * tabelaCusto[next.tecnologia];
     }
     else if(next.filhos){
       return prev + next.quantidade * next.filhos.reduce(cb, 0);
     } else { //doesn't have tecnologia nor filhos
       return;
     }
   }

   return arvoreArquitetura.reduce(cb, 0);
}
about 4 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda