ISSUE
I am using a variable called var addedToCart = 0;
. How to set a max and min value so that user cannot click more or less than the specified value and var addedToCart
will not store the out of range value?
When + icon
clicked add value to addedToCart
When - icon
clicked subtract value from addedToCart
but within specified range
You can simply use if statement
var MIN = 0;
...
if(value > MIN){
setState({
addedToCart--;
})
}
...
if(value < MAX){
setState({
addedToCart++;
})
}