Skip to content

Instantly share code, notes, and snippets.

@smarttonna
Created October 19, 2019 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smarttonna/330345e603d47752ee4a5c80df4262ed to your computer and use it in GitHub Desktop.
Save smarttonna/330345e603d47752ee4a5c80df4262ed to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/jabacuv
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
class BankAccount{
constructor(owner,balance){
this.owner = owner;
this.balance = balance;
}
showBalance(amount){
console.log("Balance " + this.balance + "NGN");
}
withdraw(amount){
if(this.balance < amount){
console.log("Insufficient Balance");
}
else{
this.balance -= amount;
this.showBalance();
}
}
deposite(amount){
this.balance += amount;
this.showBalance();
}
}
const newOwner = new BankAccount("Amazu Tonna",5000);
newOwner.withdraw(8000);
newOwner.deposite(3000);
</script>
<script id="jsbin-source-javascript" type="text/javascript">class BankAccount{
constructor(owner,balance){
this.owner = owner;
this.balance = balance;
}
showBalance(amount){
console.log("Balance " + this.balance + "NGN");
}
withdraw(amount){
if(this.balance < amount){
console.log("Insufficient Balance");
}
else{
this.balance -= amount;
this.showBalance();
}
}
deposite(amount){
this.balance += amount;
this.showBalance();
}
}
const newOwner = new BankAccount("Amazu Tonna",5000);
newOwner.withdraw(8000);
newOwner.deposite(3000);
</script></body>
</html>
class BankAccount{
constructor(owner,balance){
this.owner = owner;
this.balance = balance;
}
showBalance(amount){
console.log("Balance " + this.balance + "NGN");
}
withdraw(amount){
if(this.balance < amount){
console.log("Insufficient Balance");
}
else{
this.balance -= amount;
this.showBalance();
}
}
deposite(amount){
this.balance += amount;
this.showBalance();
}
}
const newOwner = new BankAccount("Amazu Tonna",5000);
newOwner.withdraw(8000);
newOwner.deposite(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment