Guest User

Untitled

a guest
Apr 26th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #!/usr/local/bin/node
  2.  
  3.  
  4. let amountAdded = 0;
  5.  
  6. const bank = {
  7.   accounts: [
  8.     {name: "Anna", balance: 10000},
  9.     {name: "Ben", balance: 20000},
  10.     {name: "Linda", balance: 102}
  11.   ],
  12.  
  13.   totalMoney: function() {
  14.  
  15.     for (let i = 0; i < this.accounts.length; i++) {
  16.     console.log("Account Balance: " + this.accounts[i].balance);
  17.     amountAdded += this.accounts[i].balance;
  18.     
  19.    }
  20. return amountAdded;
  21. }
  22.  
  23. };
  24.  
  25. console.log("Total " + bank.totalMoney())
Add Comment
Please, Sign In to add comment