Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1)
- function checkBalance(balance, withdrawAmount){
- if (balance >= withdrawAmount){
- return true;
- }
- return false;
- }
- function withdraw(withdrawAmount){
- return withdrawAmount;
- }
- const run () =>{
- if(this.checkBalance(balance, withdrawAmount)){
- this.withdraw(withdrawAmount);
- }else{
- alert("insufficient funds");
- }
- }
- 2)
- function checkBalance(balance, withdrawAmount){
- if (balance >= withdrawAmount){
- this.withDraw(withdrawAmount)
- }else{
- alert("insufficient funds");
- }
- }
- function withDraw(withdrawAmount){
- return withdrawAmount;
- }
- const run () =>{
- this.checkBalance(balance, withdrawAmount)
- }
- I personally feel like 1) is better, because nested calls will add complexity to the logic, but what do you guys think?
- I am more interested in what would be the best method, the code is just a simple example
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement