Question: Consider the following code :

```
import React, { Component } from 'react';

class Counter extends Component {
  state = { value: 5 };

  increment = () => {
    this.setState(prevState => ({
      value: prevState.value + 1
    }));
  };

  decrement = () => {
    this.setState(prevState => ({
      value: prevState.value - 1
    }));
  };

  render() {
    return (
      <div>
        {this.state.value}
        <button onClick={this.increment}>+</button>
        <button onClick={this.decrement}>-</button>
      </div>
    )
  }
}

```

How can I make it so that whenever I click the Decrement button, the value will not be less than 0. The value's minimum will always be zero and not -1, -2 ,-3 ,-4 ...

Answer: 
Just set a minimum value in your decrementing code:

```
decrement = () => {
  this.setState(prevState => ({
    value: Math.max(prevState.value - 1, 0)
  }));
};

```
**On Way Use Conditional (ternary) operator in decrement Function**

```
     decrement = () => {
        this.setState(prevState => ({
          value: prevState.value ? prevState.value -1 : 0
        }));
      };

```