Sorry for the noob question, but I have been struggling for a couple of hours here. I want to make an automatic slider with buttons, but the function showSlides doesn't inherit the slideIndex value from currentSlide. Here's my code:

```js
var slideIndex = 0;
setTimeout(showSlides, 3000);
  var i;
  var n;
  var slides = document.getElementsByClassName("mySlides");

function currentSlide(slideIndex = n) {
  var i;
  var slides = document.getElementsByClassName("mySlides");

  for (i = 0; i < slides.length; i++) {
      slides[i].classList.remove('active')
  }
  console.log(slideIndex)
  slides[slideIndex].classList.add('active')
}
function showSlides() {
  var i;
  var slides = document.getElementsByClassName("mySlides");

  for (i = 0; i < slides.length; i++) {
      slides[i].classList.remove('active')
  }
    if(slideIndex == slides.length-1){
        slideIndex = 0
        } else {
        slideIndex = slideIndex+1
        }
  console.log(slideIndex)
  slides[slideIndex].classList.add('active')

  setTimeout(showSlides, 3000);
}
```