Created
June 16, 2018 23:40
-
-
Save ellijayne/74e410a3cd9a84b0d187b2538dcbd0c8 to your computer and use it in GitHub Desktop.
javascript bank - Caleb's code..
This file contains hidden or 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
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