Created
April 23, 2013 15:53
-
-
Save tlwalker/5444824 to your computer and use it in GitHub Desktop.
Envoy in Javascript - Function as Object
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
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