JavaScript
class Carousel {
constructor(images) { this.images = images; this.current = 0; }
next() { this.current = (this.current + 1) % this.images.length; }
prev() { this.current = (this.current - 1 + this.images.length) % this.images.length; }
getCurrent() { return this.images[this.current]; }
}Output
// Carousel functionality
Image Carousel displays images in rotation.