Implement the following functionality in JavaScript:
-
- Create a Function constructor that creates Bank Accounts
-
- Implement the following prototype methods:
- 2.1.
deposit
: will deposit an amount to the current balance - 2.2.
withdraw
: will withdraw an amount from the current balance and return the withdrawn amount- Validation rules include:
- 2.2.1. Amount must not be negative number
- 2.2.2. Amount must be of type Number
- 2.2.3. Amount must not exceed current balance
- 2.3.
getBalance
: will return the current balance -
- Automatically give a new IBAN number to new accounts. (Static property)
IMPLEMENTATION EXAMPLE:
const newAccount = new Account( "Kostas Minaidis" );
// New account created for: Kostas Minaidis
// IBAN: GR00010003
newAccount.getBalance() // 0
newAccount.deposit( 100 )
newAccount.getBalance() // 100
newAccount.withdraw( 50 )
newAccount.getBalance() // 50
newAccount.withdraw( 500 ) // Error 'Insufficient balance!'
newAccount.withdraw( "50" ) // Error 'Invalid amount'
newAccount.withdraw( -150 ) // Error 'Invalid amount'
Push your solution, create the pull request and submit its URL..