diff --git a/Sprint-3/slideshow/index.html b/Sprint-3/slideshow/image-carousel.html similarity index 100% rename from Sprint-3/slideshow/index.html rename to Sprint-3/slideshow/image-carousel.html diff --git a/Sprint-3/slideshow/slideshow.js b/Sprint-3/slideshow/slideshow.js index 063ceefb..93aec9d4 100644 --- a/Sprint-3/slideshow/slideshow.js +++ b/Sprint-3/slideshow/slideshow.js @@ -5,4 +5,23 @@ const images = [ ]; -// Write your code here \ No newline at end of file +// Write your code here + +//1: get element needed +const backwardButton = document.querySelector("#backward-btn"); +const forwardButton = document.querySelector("#forward-btn"); +const carouselImage = document.querySelector("#carousel-img"); + +let currentIndex = 0; + +backwardButton.addEventListener("click", () => { +// access the images array and replace current image with next image on the list. + currentIndex = (currentIndex - 1 + images.length) % images.length; + carouselImage.src = images[currentIndex]; // Update image source +}); + +forwardButton.addEventListener("click", () => { +// access the images array and replace current image with next image on the list. + currentIndex = (currentIndex + 1 + images.length) % images.length; + carouselImage.src = images[currentIndex]; // Update image source +}); \ No newline at end of file