Guest User

Untitled

a guest
Jun 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. const bank = {
  2. //empty array of accounts
  3. accounts: [],
  4.  
  5. //add account function pushing into the empty accounts array.
  6. addAccount: function (name, money) {
  7.  
  8. let newAccount = {
  9. accountName: name,
  10. balance: money,
  11. }
  12. accounts.push(newAccount);
  13. },
  14.  
  15. //total sum of accounts in bank
  16. total: function () {
  17. let tot = 0;
  18. for (let i = 0; i < bank.accounts.length; i++) {
  19. tot = tot + bank.accounts.balance[i];
  20. }
  21.  
  22. }
  23.  
  24. }
  25.  
  26. bank.addAccount("Caleb", 2322);
Add Comment
Please, Sign In to add comment