I am trying to change the background color when the button is clicked. But instead of the color being changed sequentially when I click the button, it directly changes to the last one. How do I fix it by using for loop only.
but.addEventListener("click", clickfunction);
function clickfunction() {
color = arr.shift();
arr.push(color);
bgcolor.style.background = color;
but.style.color = color;
but.innerText = color;
comming[0].style.background = --color;
};