Codetive
Sign In
Coding challenges as of now are only available on desktop
On mobile you can try our quiz
Quiz
We are working hard to bring coding challenges with editor on mobile 💚

Note: This challenge focuses more on logic than UI. If you want to also focus on and practice UI, visit our UI Components challenges.

Objective: Implement an infinite carousel component that allows users to cycle through items.

Instructions:

  1. Create a carousel that displays a series of items (e.g., images or cards) one at a time.
  2. The carousel should loop infinitely, meaning that when the user reaches the last item, it cycles back to the first, and vice versa.
  3. Include "Next" and "Previous" buttons to allow users to navigate through the items.

Requirements:

  • The carousel should loop infinitely, so users can navigate through the items without reaching an end.
  • Add at least 5 items.

Hints:

  1. Use a state variable or index to track the current item in the carousel.
  2. Reset the index to the start or end when it goes out of bounds to create the infinite loop.
  3. Use a timer or interval to handle the automatic cycling of items (bonus).

Bonus:

  1. Automatic cycling - The carousel automatically cycles through the items after a set interval.
Browser
Console
Tests
Soon