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

Programming Exercises

Create a counter component using useReducer with increment, decrement, and reset actions.

Medium

Problem Statement

Create a counter component using useReducer with increment, decrement, and reset actions.

Sample Input

Initial counter value: 0

Sample Output

Increment, decrement, and reset the counter.

Limits

Time: 2s · Memory: 256 MB

Code Editor

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

import React, { useReducer } from "react";
 
 const Counter = () => {
  return (
  <div>
  <p>Counter: 0</p>
  <button>Increment</button>
  <button>Decrement</button>
  <button>Reset</button>
  </div>
  );
 };
 
 export default Counter;