Created
March 10, 2019 10:17
-
-
Save jasongorman/aef1d8f117f71225047d6fa4fbdc045d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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