Hello Everyone,
I have done the task according to the instructions and it works, but I don’t understand why it doesn’t work when I try to do it another way without the class attribute involved. The ‘darken’ button doesn’t iterate. Can you please assist me in this. The link to my code is https://glitch.com/edit/#!/image-gallery-task
Hello @Osbond
you doing great well done
for this
btn.onclick = function() {
for(let i=0; i<2; i++) {
if (i){
btn.textContent = "Lighten"
overlay.style.backgroundColor = 'rgba(0,0,0,0.5)';
} else{
btn.textContent = 'darken'
overlay.style.backgroundColor = 'rgba(0,0,0,0)';
}
}
}
your loop will do the following it will set the button to light on first cycle of the loop when i =0 then the loop continuo so i will be 1 then it wil set button to dark
but since it very small code you would not notice that changed so fast but even if it long code that at the end of the loop it will set the button to dark
hope that help and have a nice day