What happens when you use the `once` option?
document.addEventListener("DOMContentLoaded", (event) => //runs after page fully loaded
getRandomNumber();
alert("DomContentLoaed");
}, {once: true});
Is the submit button in a form? If so, it could be that pressing the submit button causes a page reload, which calls the `DOMContentLoaded` event to fire a second time.