Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const bankAccount = (() => {
- let _ballance = 2000;
- let deposit = (sum) => {
- if (typeof sum !== 'number'){
- throw error;
- }
- return _ballance =+ sum
- }
- let withdraw = (sum) => {
- if (typeof sum !== 'numner'){
- throw new Error;
- } else if ( sum > _ballance) {
- throw console.error('No money no honey');
- }
- return _ballance += sum;
- }
- let getBallance = () =>{
- return _ballance
- }
- return {
- deposit,
- withdraw,
- getBallance
- }
- })()
- let account = bankAccount;
- console.log( account.getBallance())
- account.deposit(1000);
- console.log( account.getBallance())
Advertisement
Add Comment
Please, Sign In to add comment