| 1 | class Bank { |
| 2 | constructor(balance) { |
| 3 | this.balance = balance |
| 4 | } |
| 5 | |
| 6 | withdraw(amount) { |
| 7 | // guard clause |
| 8 | if (this.balance - amount <= 0) { |
| 9 | console.log('❌ You cannot withdraw more than what you have!') |
| 10 | console.log({balance: this.balance}) |
| 11 | return |
| 12 | } |
| 13 | |
| 14 | this.balance -= amount |
| 15 | console.log('withdrew', `$${amount}`) |
| 16 | console.log({balance: this.balance}) |
| 17 | } |
| 18 | |
| 19 | deposit(amount) { |
| 20 | this.balance += amount |
| 21 | console.log('deposited', `$${amount}`) |
| 22 | console.log({balance: this.balance}) |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | const qaziChecking = new Bank(0) |
| 27 | // console.log(qaziChecking.balance) |
nothing calls this directly
no outgoing calls
no test coverage detected