I have a simple slideShow with a next and previous button. Here are my functions:
function nextSlide(){
_currentSlide++;
_nextSlide = _currentSlide % _slides.length;
}
function prevSlide(){
if(_currentSlide == 0) _currentSlide = _slides.length;
_currentSlide--;
_prevSlide = _currentSlide % _slides.length;
}
While this works, I’m wondering (within my prevSlide function) if I can avoid using the “if conditional” altogether?
Yes you can: