Skip to content

Instantly share code, notes, and snippets.

@prio101
Created December 4, 2014 14:35
Show Gist options
  • Save prio101/c514ecf52bdd3178ceac to your computer and use it in GitHub Desktop.
Save prio101/c514ecf52bdd3178ceac to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var checking , savings ;
// This is the defination of our accounts
function Account(accountNumber){
// This is the property we'll be storing the account number in
this.accountNumber = accountNumber ;
// this is the property we will be tracking the accounts funds
this.funds = 0 ;
//this is the setter method we'll be adding the funds in
this.deposit = function(amount){
if(amount === Number(amount)){
this.funds += amount;
}
} ;
//The getter method of that returns the accounts balance
this.balance = function(){
return this.funds;
} ;
}
checking = new Account("6786876866");
checking.deposit(12.78);
checking.deposit(87.90);
checking.deposit(24.01);
savings= new Account("12651251725") ;
savings.deposit(34354.90);
checking.balance();
savings.balance();
</script>
<script id="jsbin-source-javascript" type="text/javascript">var checking , savings ;
// This is the defination of our accounts
function Account(accountNumber){
// This is the property we'll be storing the account number in
this.accountNumber = accountNumber ;
// this is the property we will be tracking the accounts funds
this.funds = 0 ;
//this is the setter method we'll be adding the funds in
this.deposit = function(amount){
if(amount === Number(amount)){
this.funds += amount;
}
} ;
//The getter method of that returns the accounts balance
this.balance = function(){
return this.funds;
} ;
}
checking = new Account("6786876866");
checking.deposit(12.78);
checking.deposit(87.90);
checking.deposit(24.01);
savings= new Account("12651251725") ;
savings.deposit(34354.90);
checking.balance();
savings.balance();</script></body>
</html>
var checking , savings ;
// This is the defination of our accounts
function Account(accountNumber){
// This is the property we'll be storing the account number in
this.accountNumber = accountNumber ;
// this is the property we will be tracking the accounts funds
this.funds = 0 ;
//this is the setter method we'll be adding the funds in
this.deposit = function(amount){
if(amount === Number(amount)){
this.funds += amount;
}
} ;
//The getter method of that returns the accounts balance
this.balance = function(){
return this.funds;
} ;
}
checking = new Account("6786876866");
checking.deposit(12.78);
checking.deposit(87.90);
checking.deposit(24.01);
savings= new Account("12651251725") ;
savings.deposit(34354.90);
checking.balance();
savings.balance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment