I want to show a loading screen until a while loop completes. Here is some code to briefly illustrate the principle behind my problem. I need to be using a while loop for the logic I have. The while loop's execution time will significantly vary based on user input.
var x = 0;
var y = 100;
document.getElementById("x").style.display = "block";
while (x < y) {
x++;
}
document.getElementById("x").style.display = "none";
console.log("done");
The issue is in updating the DOM after execution. Console logs fine, but the element's style doesn't change so that it disappears.