<commit_before>//
//  Bank Account
//  bankAccount.js
//
//  Created by <NAME> on 10/17/15.
//  Copyright (c) 2015 ddApps. All rights reserved.
//  ------------------------------------------------
//

var account = {
	balance: 0
};

var deposit = function(account, amount) {
	console.log("Deposit of " + amount);
	account.balance += amount;
}

var withdrawal = function(account, amount) {
	console.log("Withdrawal of " + amount);
	account.balance -= amount;
}

var getBalance = function(account) {
	return account.balance;
}

var printBalance = function(account) {
	console.log("Current Balance: " + getBalance(account));
}
 

// Bank Test Run: deposit $10, Withdraw $5. Result = $5
printBalance(account);
deposit(account, 10);
printBalance(account);
withdrawal(account, 5);
printBalance(account);<commit_msg>Added an Array of Accounts to support multiple account creation<commit_after>//
//  Bank Account
//  bankAccount.js
//
//  Created by <NAME> on 10/17/15.
//  Copyright (c) 2015 ddApps. All rights reserved.
//  ------------------------------------------------
//


// Array of Accounts
var accounts = [];


// Creates an account and adds it to the array of accounts
// Returns: an account object
var createAccount = function(account) {
	accounts.push(account);
	return account;
}


// Finds matching accounts using a forEach on the array of accounts
var getAccount = function(username) {
	var matchingAccounts = [];
	accounts.forEach(function(account){
		if (username === account.username) matchingAccounts.push(account);
	});
	return matchingAccounts;
}

var deposit = function(account, amount) {
	console.log("Deposit of " + amount);
	account.balance += amount;
}


var withdrawal = function(account, amount) {
	console.log("Withdrawal of " + amount);
	account.balance -= amount;
}


var getBalance = function(account) {
	return account.balance;
}


var printBalance = function(account) {
	console.log("Current Balance: " + getBalance(account));		
}
 

// Bank Test Run: create an 'A' and 'B' account, deposit $10 into 'A', Withdraw $5 from 'B'. Result = A($10), B(-$5).

var AAccount = createAccount({
	balance: 0,
	username: "A"
});

var BAccount = createAccount({
	balance: 0,
	username: "B"
});

var account = getAccount("A");
console.log("Matches = " + account.length);

printBalance(AAccount);
deposit(AAccount, 10);
printBalance(AAccount);
withdrawal(BAccount, 5);
printBalance(BAccount);
{'fraction_non_alphanumeric': 0.17796257796257797, 'fraction_numerical': 0.016216216216216217, 'mean_word_length': 3.4473197781885396, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2241204', 'n_tokens_mistral': 784, 'n_tokens_neox': 747, 'n_words': 213}