title: How to add an item to the cart
body: <p>I don't really understand this function, like what does the &quot;<em>cartItems.push(...product, count:1)</em>&quot; actually do? I am a begginer and it's hard for me to understand these logic. It'd be kind of you guys to help me to explain! Thank you so much!</p>
  <pre><code>addToCart = (product) =&gt; {
      let alreadyIncart = false;
      const cartItems = this.state.cartItems.slice()
      cartItems.forEach((item) =&gt; {
        if(item.id===product.id){
          item++;
          alreadyIncart = true;
        }
        if(!alreadyIncart){
          cartItems.push(...product, count:1)
        }
      })
    }
  </code></pre>