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

138
Vistas
Merge multiple outputs from multiple functions into one array in Javascript?

Example

I have these values, there is any way to put them together in a single array?

This is one of the functions that make the results, they take their data from a database.

function AddvotoTec(votor) {
  class Avg {
    constructor() {}
    static average(votor) {
      var total = 0;
      var count = 0;
      jQuery.each(votor, function(index, value) {
            total += value;
            count++;
      });
      return total / count;
    }
  }
  var mvoti = Avg.average(votor);
  voti(mvoti);
}

function voti(Voti) {
  var voti = [];
  voti.push(Voti);
  console.log(voti);
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your problem is you put var voti = [] in the function that will initialize a new array every time you call it. If you want to push data to that array, you should move it out from voti(Voti) function

function AddvotoTec(votor) {
  class Avg {
    constructor() {}
    static average(votor) {
      var total = 0;
      var count = 0;
      jQuery.each(votor, function(index, value) {
            total += value;
            count++;
      });
      return total / count;
    }
  }
  var mvoti = Avg.average(votor);
  voti(mvoti);
}

var voti = []; //move the array to the outer scope
function voti(Voti) {
  voti.push(Voti);
  console.log(voti);
}
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