Challenge: Command Pattern

In this challenge, you have to implement the command pattern to solve the given problem.

Problem statement

Study and run the code snippet below:

Press + to interact
class BankAccount {
constructor(amount){
this.amount = amount
}
checkAmount() {
console.log(this.amount)
}
withdrawMoney(withdrawamount) {
if(withdrawamount > this.amount){
console.log("Not enough money")
}
else{
this.amount -= withdrawamount
}
}
depositAmount(money){
this.amount += money
}
}
var account = new BankAccount(100)
account.checkAmount()
account.withdrawMoney(10)
account.checkAmount()
account.depositAmount(50)
account.checkAmount()

In the code above, you have a BankAccount class. You can ...