title: I want to generate random number in method once which are not same with previous one
body: <p>I have to change background image in method. Background images are coming from this.items service but when method runs new background image shouldn't be same with previous one.
   When I run this method it changes images but new image can be same with previous one. How can I do?</p>
  
  <pre><code>export class GridManager {
      changeBackground() {
          var x = Math.floor(Math.random() * document.querySelectorAll(".grid-item").length);
          if (this.items[x].backgroundImage != "" &amp;&amp; this.items[x].backgroundImage != null) {
              document.querySelector(".container").style.backgroundImage = `url('${this.items[x].backgroundImage}')`;
          }
      }
  }
  </code></pre>