All Challenges

Image Carousel / Slider with Keyboard & Dot Nav

HTML/CSSMediumAmazonFlipkartAirbnb
30:00

Problem Brief

Build an accessible carousel with Next/Prev wrap-around controls, indicator dots, active slide tracking, and Left/Right arrow key navigation.

Requirements

  • Render slides inside `[data-testid="carousel"]` with `[data-testid="slide-caption"]`.
  • Clicking `[data-testid="next-slide"]` and `[data-testid="prev-slide"]` cycles cleanly with modulo wrap-around.
  • Clicking dot `[data-dot="N"]` jumps directly to slide index N.
  • ArrowLeft / ArrowRight keydown events on carousel advance or rewind slides.
Progressive Hints (1)
  • Compute wrapped index with `((index + slides.length) % slides.length)`.
Reference Solution

Stuck? Load the verified reference code into your editor.

Automated Test Suite

2 Test Cases Ready
  • Wraps around Prev from 0 to last and Next from last to 0Prev on first slide wraps to Slide 3; Next wraps back to Slide 1
  • Jumps directly via dot buttons and Arrow keysDot click jumps to Slide 2 and ArrowRight moves to Slide 3
solution.html
Live Sandboxed Previewiframe sandbox
Starter template loaded — add your <script> logic in the editor (or open Reference Solution) to make the widget interactive.