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
00:00
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;
Log in or sign up to run or submit your code.Log inSign up
Input
Initial counter value: 0
Expected Output
Increment, decrement, and reset the counter.