Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created March 15, 2019 09:14
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/28b2406872d425035e1491f546bf4183 to your computer and use it in GitHub Desktop.
Save jasongorman/28b2406872d425035e1491f546bf4183 to your computer and use it in GitHub Desktop.
function credit(account, amount) {
return {...account, balance: account.balance + amount};
}
function debit(account, amount) {
if (amount > account.balance) {
throw "Insufficient funds error"
}
return {...account, balance: account.balance - amount};
}
module.exports = {credit, debit};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment