I am making an image slideshow in JavaScript and to better understand the code, I changed the parameter of function slideshow(n) to function slideshow(slideIndex), but noticed it didn't work, can you please help me figure out what is the difference between these two parameters of the function, and why the second parameter in function slideshow(slideIndex) doesn't work?
var slideIndex = 1;
slideshow(slideIndex);
function nextPrev(n){
slideshow(slideIndex += n);
}
function slideshow(slideIndex){
// why "function slideshow(slideIndex)" stops executing after some
// slides, however function slideshow(n) works properly here?
var x = document.getElementsByClassName("slide");
var dot = document.getElementsByClassName("dot");
if(slideIndex > x.length) slideIndex = 1;
if(slideIndex < 1) slideIndex = x.length;
for(var i=0; i < dot.length; i++){
dot[i].className = dot[i].className.replace(" active", "");
}
for(var i = 0 ; i < x.length; i++){
x[i].style.display = "none";
}
x[slideIndex-1].style.display = "block";
dot[slideIndex-1].className += " active";
}
n