var image = ['a','b', 'c', 'd','e'];
var i = image.length;
function nextImage(){
if (i<image.length) {
i= i+1;
}else{
i = 1;
}
slider_content.innerHTML = "<img src="+image[i-1]+".jpg>";
}
Because the else block of code means that i is greater or equal to the length of the array. This means the end of the array has been reached, so setting i=1
resets the slideshow back to the first image as image[i-1]
refers to the element at index 0 (the first element).