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
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.