function newAccount(aName) { var name = aName; var balance = 0; return { getDescriptionString : getDescriptionString, handleCredit : handleCredit, handleSeveralDebits : handleSeveralDebits }; function getDescriptionString() { return "\r\nThe balance of " + name + " is " + balance; } function handleCredit(amount) { balance += amount; } function handleSeveralDebits(arrayOfAmounts) { arrayOfAmounts.map(function(amount) { handleDebit(amount); }); } function handleDebit(amount) { balance -= amount; } }