chi mi può aiutare a modificare questo script per far caricare le immagini in modo random e non in ordine come avviene ora?
Grazie
codice:
    var images = [      'assets/img/bg1.jpg',
      'assets/img/bg2.jpg',
      'assets/img/bg3.jpg'
    ];
    
var img = document.querySelector('#hero');
var index = 0;
var iterations = 0;


var updateImage = function() {
  /* reset index to zero if current index is greater than number of images.
   * increment iterations variable since it means we've done one whole loop.
   */
  if (index >= images.length) {
    index = 0;
    iterations++;
  }


  // set the background image
  img.style.backgroundImage = 'url(' + images[index] + ')';
  /* clear interval (stop timer) when we've reached
   * the number of iterations allowed.
   */
  if (iterations >= 2) {
    clearInterval(interval);
  } else {
    /* increment current index in order to get next image
     * when this function gets called again.
     */
    index++;
  }
}


// update first image
updateImage();


// initiate timer
var interval = setInterval(updateImage, 4000);
Grazie