Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created March 10, 2019 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasongorman/219837a4ce00e7722fade096fa965e47 to your computer and use it in GitHub Desktop.
Save jasongorman/219837a4ce00e7722fade096fa965e47 to your computer and use it in GitHub Desktop.
function Basket(customer, items){
this.add = function(item) {
items.push(item);
}
this.checkout = function(){
const payments = new PayPalPayments();
return payments.pay(this.total(), customer.creditCard)
}
this.total = function() {
return items.reduce((sum, item) => sum + (item.price * item.quantity), 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment