Course · Section 10: A Closer Look at Functions · Lecture 144: Closures
Implement `bankOps(ops)` where `ops` is an array of amounts (positive for deposits, negative for withdrawals). Track a balance in a closure, ignore any withdrawal that would make the balance negative, and return the final balance starting from `0`.
+ 1 hidden test run on Submit.
The balance is captured privately; each operation is applied only if it keeps the balance non-negative, modeling encapsulated state.
Run your code to see results.