Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Build a counter component that increases the count by 1 every time a button is clicked.

Easy

Problem Statement

Build a counter component that increases the count by 1 every time a button is clicked.

Sample Output

Initially: Count: 0
 After clicking the button: Count: 1, Count: 2, etc.

Limits

Time: 2s · Memory: 256 MB

Code Editor

Try your code in this preview. Submit marks it done.

import React, { useState } from "react";
 
 const Counter = () => {
  const [count, setCount] = useState(0);
 
  const handleIncrement = () => {
  // Increment the count state
  };
 
  return (
  <div>
  <p>Count: {count}</p>
  <button onClick={handleIncrement}>Increment</button>
  </div>
  );
 };
 
 export default Counter;