Skip to content

Instantly share code, notes, and snippets.

@ellijayne
Created June 16, 2018 23:40
Show Gist options
  • Save ellijayne/74e410a3cd9a84b0d187b2538dcbd0c8 to your computer and use it in GitHub Desktop.
Save ellijayne/74e410a3cd9a84b0d187b2538dcbd0c8 to your computer and use it in GitHub Desktop.
javascript bank - Caleb's code..
const bank = {
//empty array of accounts
accounts: [],
};
//add account function pushing into the empty accounts array.
const addAccount = function (name, balance) {
let newAccount = {
accountName: name,
balance: balance,
}
bank.accounts.push(newAccount);
return bank;
};
console.log(addAccount("Caleb", 2322));
// //total sum of accounts in bank
// const total = function () {
// let tot = 0;
// for (let i = 0; i < bank.accounts.length; i++) {
// tot = tot + bank.accounts.balance[i];
// }
//
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment