Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!