I was following a YouTube tutorial for a Javascript Image Slider, and I came across this line of code that I'd like to better understand so that I can effectively modify it to suit my website's needs.
Here's the line:
carouselSlide.style.transform = 'translateX(' + (-size * counter) + 'px)';
carouselSlide is what contains all of the images in the image slider.
size is the width of a single image (they are all the same width).
counter increases each time a button is pressed.
The main source of my confusion is how everything is concatenated. I don't quite understand why the two single quotes are necessary inside of the translateX argument (and why they're positioned where they are), nor do I understand why the plusses are necessary.
Could someone help me understand the syntax?