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

Programming Exercises

Build a React component that increments or decrements a number using '+' and '-' buttons.

Easy

Problem Statement

Build a React component that increments or decrements a number using '+' and '-' buttons.

Sample Output

Initially: Value: 0
 Clicking '+' increments and '-' decrements the value.

Limits

Time: 2s · Memory: 256 MB

Code Editor

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

import React, { useState } from "react";
 
 const IncrementDecrement = () => {
  const [value, setValue] = useState(0);
 
  return (
  <div>
  <p>Value: {value}</p>
  <button onClick={() => {
  // Increment the value
  }}>+</button>
  <button onClick={() => {
  // Decrement the value
  }}>-</button>
  </div>
  );
 };
 
 export default IncrementDecrement;