Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Cart extends Component {
- constructor(props) {
- super(props);
- this.add = this.add.bind(this);
- }
- componentDidMount() {
- this.props.getCart();
- }
- add(array) {
- let num = [];
- let parse = [];
- console.log(array);
- for (let i = 0; i < array.length; i++) {
- parse.push(array[i].price);
- }
- console.log(parse);
- for (let i = 0; i < parse.length; i++) {
- num.push(parseInt(parse[i]));
- }
- console.log(num);
- let sum = num.reduce((acc, val) => {
- return acc + val;
- }, 0);
- console.log(sum);
- }
- render() {
- const { cart } = this.props.itemReducer;
- this.add(cart);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement