My image slideshow with prototyping is not working properly and I am struggling to fix it. I have tried binding the setInterval function but it's not working. I also attempted to wrap it, but that didn't work either. What should I do to solve this problem?
function SlideShow() {
this.currentStep = 0;
this.time = 2000;
this.images = [];
this.images[0] = 'images/image1.jpg';
this.images[1] = 'images/image2.jpg';
this.images[2] = 'images/image3.jpg';
this.images[3] = 'images/image4.jpg';
this.images[4] = 'images/image5.jpg';
}
SlideShow.prototype.runCarousel = function() {
document.querySelector('.image').src = this.images[this.currentStep];
this.currentStep < this.images.length - 1 ? this.currentStep += 1 : this.currentStep = 0;
setInterval(runCarousel.bind(SlideShow), this.time);
}
const myImageSlideShow = new SlideShow();
myImageSlideShow.runCarousel();
<div class="slide">
<img class="image" width="1000" height="500" alt="image">
</div>