New: We've launched a brand new Coding Challenges section! Check out these interactive, real-world exercises to level up your skills.Explore Challenges
FrontendPrep
ReactBeginner10 mins

Simple Counter

Loading...

Learn to build a basic counter component in React. Practice managing local component state, handling button click events, and using conditional attributes.

Arvind M
Arvind MLinkedIn

Problem Statement

Building a counter is the classic first step for learning React. It helps you understand how dynamic data changes in the browser.

In this challenge, you will build a counter component that allows users to increase, decrease, and reset a count value.


Requirements

Functional

  • Initial State: The counter must start at 0.
  • Increment: Clicking the "Increment" button must add 1 to the current count.
  • Decrement: Clicking the "Decrement" button must subtract 1 from the current count.
  • Reset: Clicking the "Reset" button must set the count back to 0.
  • Lower Bound: The counter must not go below 0. The "Decrement" button must be disabled when the count is 0.

Non-Functional

  • Keep the code clean and well-structured.
  • Use meaningful class names or CSS properties to style the counter and buttons.

Concepts Tested

  • Declaring component state with the useState hook.
  • Handling mouse events with the onClick prop.
  • Disabling buttons conditionally using HTML attributes.

Completed this coding challenge?

Mark it off to log your completion progress, or bookmark it to review trade-offs later.

Loading...

Share this Resource

Help other developers level up by sharing this study guide.

⚡ Weekly newsletter

Crack Your Next Frontend Interview.

Join senior engineers who receive practical, deep-dive frontend challenges, detailed concepts, and blueprints directly in their inbox.

  • Senior level React, JS, and CSS interview blueprints
  • System Design & performance optimization deep-dives
  • 100% free, zero spam, unsubscribe with one click

Join the Study Track

We value your privacy. Unsubscribe at any time.