You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQbw_nRUZfGp9Bma2RQDW_5l5apC36i7Rfp16ahrhvsXrUp6pmlShZH546EisOrwCsrPP9Bdlob5pFltdHlzjGOgcsobmsPP6Rl950b9iLmAw&s=10",// Local file in assets folder
5
10
];
6
11
12
+
// CURRENT IMAGE INDEX: This variable keeps track of which image we're currently showing
13
+
// We start at 0 because array indexes start at 0 (0 = first image, 1 = second image, etc.)
14
+
letcurrentImageIndex=0;
15
+
16
+
// GET HTML ELEMENTS: We find the HTML elements we need to work with
17
+
// These are like "handles" that let us control the elements with JavaScript
18
+
constcarouselImg=document.getElementById("carousel-img");// The <img> tag that shows the current picture
19
+
constbackwardBtn=document.getElementById("backward-btn");// The "Back" button
20
+
constforwardBtn=document.getElementById("forward-btn");// The "Forward" button
21
+
22
+
// FUNCTION: updateImage - This updates the webpage to show the current image
23
+
functionupdateImage(){
24
+
// Set the image source to the current image in our array
25
+
// images[currentImageIndex] gets the image path/URL at the current position
26
+
// Example: if currentImageIndex = 2, then images[2] = "./assets/cute-cat-c.jpg"
27
+
carouselImg.src=images[currentImageIndex];
28
+
29
+
// Update the alt text for accessibility (screen readers for visually impaired users)
0 commit comments