├── .editorconfig ├── index.js └── package.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | end_of_line = lf 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | charset = utf-8 10 | 11 | [*.js] 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | let balance = 500.00; 2 | 3 | class Withdrawal { 4 | 5 | constructor(amount) { 6 | this.amount = amount; 7 | } 8 | 9 | commit() { 10 | balance -= this.amount; 11 | } 12 | 13 | } 14 | 15 | 16 | 17 | 18 | // DRIVER CODE BELOW 19 | // We use the code below to "drive" the application logic above and make sure it's working as expected 20 | 21 | t1 = new Withdrawal(50.25); 22 | t1.commit(); 23 | console.log('Transaction 1:', t1); 24 | 25 | t2 = new Withdrawal(9.99); 26 | t2.commit(); 27 | console.log('Transaction 2:', t2); 28 | 29 | console.log('Balance:', balance); 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "transactions", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC" 12 | } 13 | --------------------------------------------------------------------------------