I am trying to save a random value in an array every time a user clicks on a button but the value only remains in it at the time of execution of the function.
let boton = document.getElementById('boton');
boton.addEventListener("click", iniciar);
let numeroRandom = Math.floor((Math.random() * 4) + 1);
let secuencia = [];
function iniciarluz(valor){
let elementos = document.getElementsByTagName('li');
elementos[valor-1].className = "prendida";
secuencia.push(valor);
}
function iniciar(){
iniciarluz(numeroRandom);
}