why this javascript code only works once? [duplicate]

Can someone tell me what’s wrong with this js code? it only works once, i want it to work every time i hit the document.querySelector(“.icon-right”);

const background = document.querySelector(".mainimage");
const right = document.querySelector(".icon-right");
right.addEventListener("click", () => {
  if (background.style.backgroundImage = "url(../img/1.jpg)") {
    background.style.backgroundImage = "url(../img/2.jpg)";
  } else if (background.style.backgroundImage = "url(../img/2.jpg)") {
    background.style.backgroundImage = "url(../img/3.jpg)";
  } else {
    background.style.backgroundImage = "url(../img/1.jpg)";
  }
});