Problems

Private Bank Account

MediumClosures & Scope

Build createAccount(initial) exposing deposit(n), withdraw(n) (rejected silently if insufficient), and balance(). Input: line 1 — initial balance; following lines — operations like deposit 50 or withdraw 30. Print the final balance.

Input: initial balance then operations. Output: final balance.

Your program reads from stdin and prints to stdout.

Example 1

Input: 100 deposit 50 withdraw 30

Output: 120

Hints

JavaScriptClosuresEncapsulation
Private Bank Account | CodeForge AI