Advertisement
MatthijsFontys

refactor backup

Mar 24th, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         /**
  2.          * @param {string} category
  3.          */
  4.         getProductArray(category){
  5.             const index = this.cart.findIndex( (cart) => {
  6.                 cart.category === category;
  7.             });
  8.  
  9.             let productArray;
  10.  
  11.             if(index >= 0){
  12.                 productArray = this.cart[index].products;
  13.             }
  14.             else{
  15.                 productArray = {category: category, products: []};
  16.                 this.cart.push(productArray);
  17.             }
  18.  
  19.             return productArray;
  20.         },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement