I am new to javaScript and have been self learning by watching youtubers walk-through 'beginner friendly' projects but I'm having a problem wrapping my head around parameters and how they are defined in a function.
The project is a simple image corousel and theres a certain arrow function I can't quite follow:
const slideWidth = slides[0].getBoundingClientRect().width;
slides.forEach((slide, index) => {
slide.style.left = slideWidth * index + 'px';
});
So I understand the function is using the size of the slides to determine how far to move the images to the left but I don't understand how the function understands that 'index' means the array number because the function does not define this.
I've tested this code out and it works, I just really want to understand HOW it works. I know this is a simple concept but I am a true novice who is really trying to break into the world of JavaScript, any help is appreciated.