Here I'm trying to update working
inside the setTimeout it gets updated but the addEventListener still has its old value.
const button = document.getElementById('button');
var working = true;
button.addEventListener('click', function() {
const p = document.getElementById('paragraph');
p.innerText = "Im working on something that you guys can't see";
setTimeout(() => {
working = false
}, 5000);
while (working) {
console.log(working) // This one remains true always.
}
p.textContent = "Im done";
});