title: What do I need to add to this code to stop the randomly generated images repeating themselves?
body: <p>Hello I have tried to find a solution to this and am struggling. I am very new to Javascript! This code works to generate a random image on the button click but the images randomly repeat themselves. I want to show all the images but without repeating images already shown. I understand I should add a for loop and if statement but can't figure out how to write it. These are just a few example images in the array, I will actually have 55 images in the final thing. Can anyone help me!? Thank you! :)</p>
  <p>Current code:</p>
  <pre><code>const imageArray = [
      &quot;https://images.unsplash.com/photo-1508185159346-bb1c5e93ebb4?ixlib=rb-0.3.5&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;s=55cf14db6ed80a0410e229368963e9d8&amp;auto=format&amp;fit=crop&amp;w=1900&amp;q=80&quot;,
      &quot;https://images.unsplash.com/photo-1495480393121-409eb65c7fbe?ixlib=rb-0.3.5&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;s=05ea43dbe96aba57d48b792c93752068&amp;auto=format&amp;fit=crop&amp;w=1351&amp;q=80&quot;,
      &quot;https://images.unsplash.com/photo-1501611724492-c09bebdba1ac?ixlib=rb-0.3.5&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;s=ebdb0480ffed49bd075fd85c54dd3317&amp;auto=format&amp;fit=crop&amp;w=1491&amp;q=80&quot;,
      &quot;https://images.unsplash.com/photo-1417106338293-88a3c25ea0be?ixlib=rb-0.3.5&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;s=d1565ecb73a2b38784db60c3b68ab3b8&amp;auto=format&amp;fit=crop&amp;w=1352&amp;q=80&quot;,
      &quot;https://images.unsplash.com/photo-1500520198921-6d4704f98092?ixlib=rb-0.3.5&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;s=ac4bc726064d0be43ba92476ccae1a75&amp;auto=format&amp;fit=crop&amp;w=1225&amp;q=80&quot;,
      &quot;https://images.unsplash.com/photo-1504966981333-1ac8809be1ca?ixlib=rb-0.3.5&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;s=9a1325446cbf9b56f6ee549623a50696&amp;auto=format&amp;fit=crop&amp;w=1350&amp;q=80&quot;
  ];
  
  const image = document.querySelector(&quot;img&quot;);
  const button = document.querySelector(&quot;button&quot;);
  
  window.onload = () =&gt; generateRandomPicture(imageArray);
  
  button.addEventListener(&quot;click&quot;, () =&gt; generateRandomPicture(imageArray));
  
  function generateRandomPicture(array){
      let randomNum = Math.floor(Math.random() * array.length); 
      image.setAttribute(&quot;src&quot;, array[randomNum]);
  }
  </code></pre>