In Below, why does while loop run before document.body.style.backgroundColor assignment?
console.log("loadded");
const btn = document.getElementById("button");
btn.addEventListener("click", () => {
document.body.style.backgroundColor = "red";
const start = Date.now();
const delaySeconds = 10;
while (Date.now() < start + delaySeconds * 1000) {}
});
<button id="button">test</button>