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

209
Visualizações
trying to make an array getting new values through function, then return it as global
var doc = document;
var k;
var array1 = [];
var select = doc.getElementById("select");
var select = doc.getElementById("select");
var divP   = doc.getElementById("poeng" );
var divH   = doc.getElementById("helse" );
var runder = doc.getElementById("rundeQ");
var form1  = doc.getElementById("form1" );
form1.onsubmit = function(evt){ 
evt.preventDefault()
Window.k = array1.push("yay")
}
console.log(k)

what you are seeing is an attempt to make a global array that adds new values in function, i want to use this value later therefore trying to get that new array value available globally for the next functions aka making it globally. any tips how i can make it work? so the thing is i want to have multiple buttons that all returns thorugh function, to an array globally. then i can use the last value of everytime

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

var doc = document;
var k;
var array1 = [];
var select = doc.getElementById("select");
var select = doc.getElementById("select");
var divP   = doc.getElementById("poeng" );
var divH   = doc.getElementById("helse" );
var runder = doc.getElementById("rundeQ");
var form1  = doc.getElementById("form1" );
form1.onsubmit = function(evt){ 
    evt.preventDefault()
    window.k = array1;
}
console.log(k)

You can use window object for this. Dont use window.k = array1.push(value); Because push() returns length of the result array.

about 4 years ago · Santiago Trujillo 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