//HTML
 <img name="slide" />
    

//Javascript
let i = 0; // Start Point
let images = []; // Images Array
let time = 3000; // Time Between Switch

// Change Image
function changeImg() {
  // Image List
  images[i] = `img-${i}.jpg`;
  images.length = 4;

  document.slide.src = images[i];
  // Check If Index Is Under Max
  if (i < images.length - 1) {
    // Add 1 to Index
    i++;
  } else {
    // Reset Back To O
    i = 0;
  }

  // Run function every x seconds
  setTimeout('changeImg()', time);
}

// Run function when page loads
window.onload = changeImg;