Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

137
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda