Last active
January 5, 2022 22:31
-
-
Save caglarorhan/6e9c04d04ced6d0cc9e97efe4f800f4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const account = { | |
balance: 0 | |
}; | |
const accountProcesses= {}; | |
// Account processes - as many as we want | |
accountProcesses.deposit = { | |
process:(amount)=>{ | |
account.balance += amount; | |
} | |
}; | |
accountProcesses.withdraw = { | |
process:(amount)=>{ | |
account.balance -= amount; | |
} | |
}; | |
function doProcess(processType, amount) { | |
processType?.process(amount); | |
return account.balance; | |
} | |
console.log(doProcess(accountProcesses.deposit, 100)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment