Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const bank = {
- //empty array of accounts
- accounts: [],
- //add account function pushing into the empty accounts array.
- addAccount: function (name, money) {
- let newAccount = {
- accountName: name,
- balance: money,
- }
- accounts.push(newAccount);
- },
- //total sum of accounts in bank
- total: function () {
- let tot = 0;
- for (let i = 0; i < bank.accounts.length; i++) {
- tot = tot + bank.accounts.balance[i];
- }
- }
- }
- bank.addAccount("Caleb", 2322);
Add Comment
Please, Sign In to add comment