title: Repeat background images of a div
body: <p>I am trying to change the background images of a div, but somehow it runs once and shows the last image and not iterating.</p>
  <p>JS</p>
  <pre><code>let wrapper = document.querySelector('.wrapper');
  let backImages = ['backimage1.jpg', 'backimage2.jpg', 'backimage3.jpg'];
  
  // First way
  setInterval(() =&gt; {
    for (let bg in backImages) {
      wrapper.style.background = `url('${backImages[bg]}')`;
    }
  }, 3000);
  
  // Second way
  let changeBg = () =&gt; {
    for (let bg in backImages) {
      wrapper.style.background = `url('${backImages[bg]}')`;
    }
  };
  
  setInterval(changeBg, 3000);
  </code></pre>
  <p>How can I make it so that it keep iterating over all images endlessly.</p>