Course · Section 14: Object-Oriented Programming (OOP) With JavaScript · Lecture 226: ES6 Classes
Model a bank account that rejects overdrafts. Implement `BankAccount` (starting balance 0): - `deposit(amount)` adds funds and returns true. - `withdraw(amount)` returns false if it would overdraw, otherwise subtracts and returns true. - `getBalance()` returns the current balance.
+ 1 hidden test run on Submit.
Encapsulating the balance and validating withdrawals enforces the overdraft rule.
Run your code to see results.