Skip to content

Instantly share code, notes, and snippets.

@katelynsills
Last active January 24, 2019 01:01
Show Gist options
  • Save katelynsills/b1420ae0ee85e7547fe11a9064d9c037 to your computer and use it in GitHub Desktop.
Save katelynsills/b1420ae0ee85e7547fe11a9064d9c037 to your computer and use it in GitHub Desktop.
function makeBankAccount(balance) {
stateHolder.updateState(balance);
return {
withdraw(amount) {
balance -= amount;
stateHolder.updateState(balance);
},
deposit(amount) {
balance += amount;
stateHolder.updateState(balance);
},
getBalance() {
return balance;
},
};
}
const bankAccount = makeBankAccount(4000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment