score:0

Accepted answer
  handleChange = (e, id) => {
    const { products } = this.state;
    const indexProduct = products.findIndex(product => product.id === id);
    products[indexProduct].quantity = Number(e.target.value);
    this.setState({ products });
  };

score:0

products.map(product => {
  numberItems += Number(product.quantity);
  console.log(numberItems);
  subTotal += Number(product.price) * Number(product.quantity);
});

score:0

    products.map(product => {
      numberItems += product.quantity;
      subTotal += product.price * product.quantity;
      return { numberItems, subTotal  }
    });

Related Query

More Query from same tag