Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created March 10, 2019 10:17
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/aef1d8f117f71225047d6fa4fbdc045d to your computer and use it in GitHub Desktop.
Save jasongorman/aef1d8f117f71225047d6fa4fbdc045d to your computer and use it in GitHub Desktop.
const paypalPayments = require('./paypalpayments.js');
function Basket(customer, items){
this.add = function(item) {
items.push(item);
}
this.checkout = function (payments) {
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