Created
September 24, 2014 04:28
-
-
Save javaeeeee/9a3c815c6712b3ecb025 to your computer and use it in GitHub Desktop.
BankAccount 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 myBankAccount = { | |
balance: 0, | |
ownerName: "", | |
isEnoughMoney: function (amount) { | |
return balance > amount; | |
}, | |
deposit: function (amount) { | |
this.balance += amount; | |
}, | |
withdraw: function (amount) { | |
if (this.isEnoughMoney(amount)) { | |
this.balance -= amount; | |
} | |
}, | |
getBalance: function () { | |
return this.balance; | |
} | |
}; | |
//The balance is corrupted | |
myBankAccount.balance = 20; | |
//Here we call a method | |
console.log("balance = " + myBankAccount.getBalance()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment