{"size": 630, "ext": "js", "max_stars_repo_path": "server/api/apiUtils.js", "max_stars_repo_name": "camc-graceshopper-project/graceshopper-project", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/api/apiUtils.js", "max_issues_repo_name": "camc-graceshopper-project/graceshopper-project", "max_issues_repo_issues_event_min_datetime": "2019-04-16T14:35:39.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-23T14:50:40.000Z", "max_forks_repo_path": "server/api/apiUtils.js", "max_forks_repo_name": "camc-graceshopper-project/graceshopper-project", "max_forks_repo_forks_event_min_datetime": "2021-01-18T19:53:26.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-18T19:53:26.000Z"}
{"max_stars_count": null, "max_issues_count": 52, "max_forks_count": 1, "avg_line_length": 20.3225806452, "max_line_length": 80, "alphanum_fraction": 0.6333333333}
module.exports = {};

const addToCart = function (cart, newItem) {
  if (cart.some((cartItem) => {
    return cartItem.id === newItem.id
  })) {
    cart.forEach((cartItem) => {
      if (cartItem.id === newItem.id) {
        cartItem.cart.quantity = cartItem.cart.quantity + newItem.cart.quantity;
      }
    })
  } else {
    cart.push(newItem);
  }
  
  return cart;
  
}

const removeFromCart = function(cart, oldItem) {
  let newCart = cart.filter((currentItem) => {
    return (currentItem.id !== oldItem.id)
  })
  return newCart;
}


module.exports.addToCart = addToCart;
module.exports.removeFromCart = removeFromCart;

