Skip to content

Instantly share code, notes, and snippets.

@tlwalker
Created April 23, 2013 15:53
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 tlwalker/5444824 to your computer and use it in GitHub Desktop.
Save tlwalker/5444824 to your computer and use it in GitHub Desktop.
Envoy in Javascript - Function as Object
var balance = 0;
var withdraw = function (amount){
if(balance >= amount){
balance = balance - amount;
} else {
throw new Error('Insufficient funds')
}
}
var deposit = function (amount) {
balance = balance + amount;
}
var accrueInterest = function (interestRate) {
balance = balance * (100 + interestRate);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment