I am currently working on a module where exam information is stored in an array and passed to another JavaScript file using localStorage. However, I'm facing an issue where the previous exam data keeps getting overwritten despite using .push method. All the variables have been defined elsewhere. Any help would be greatly appreciated. Below is the code snippet:
recentexamdb = []
document.getElementById("button1").onclick = function () {
window.scrollTo(0, 0);
document.getElementById("maindiv").style.visibility = "hidden";
document.getElementById("buttondiv").style.visibility = "hidden";
document.getElementById("countdown").style.visibility= "visible";
var yearinput = document.getElementById("yearinput").value;
var minuteinput = document.getElementById("minuteinput").value;
var hourinput = document.getElementById("hourinput").value;
var secondinput = document.getElementById("secondinput").value;
// rest of the code goes here...
}