title: How to replace an object property value in redux
body: <p>I am trying to create an online shop using redux. I have got it so that a person can add an item to their basket. However, having difficulty with adding quantity. I have a method that works that wont let someone add the same product twice, I just need to now make it increase the quantity for that same product.</p>
  
  <p>My basket state is stored as an array of objects. </p>
  
  <p>This is my basket reducer:</p>
  
  <pre><code>const initialState = [];
  
  const isProductInBasket = (state, action) =&gt; {
    for (var i=0; i &lt; state.length; i++){
      if(state[i].product.id == action.data.product.id){
        return true;
      }
    }
  }
  
  export default (state = initialState, action) =&gt; {
    switch(action.type) {
      case "ADD_TO_BASKET":
        if (isProductInBasket(state, action)) {
          for (var i=0; i &lt; state.length; i++){
            if(state[i].product.id = action.data.product.id){
              console.log(state, 'stst');
              const basketState = state[i].product.quantity + 1;
              return {...state, basketState}; //problem is here
            }
          }
        }
        else {
          const basketState = [].concat(state).concat(action.data)
          return basketState;
          break;
        }
      default:
          return state
    };
  };
  </code></pre>
  
  <p>Clearly what im doing is wrong as im returning an object, but im wondering how i can return that new object in place of the old object. i need to return it as an object but inside an array...</p>
  
  <p>just to be uber clear, when I have this:</p>
  
  <pre><code>{name: "Rucksack", price: "15.00", id: 1, quantity: 0}
  </code></pre>
  
  <p>and I click add to basket, it should then come back as:</p>
  
  <pre><code>{name: "Rucksack", price: "15.00", id: 1, quantity: 1}
  </code></pre>