Skip to content

Instantly share code, notes, and snippets.

@claudiainbytes
Created August 26, 2017 17:33
Show Gist options
  • Save claudiainbytes/a341de2660b22d039c1c5c5435b263a7 to your computer and use it in GitHub Desktop.
Save claudiainbytes/a341de2660b22d039c1c5c5435b263a7 to your computer and use it in GitHub Desktop.
/*
* Programming Quiz: Bank Accounts 1 (7-3)
*/
var savingsAccount = {
balance: 1000,
interestRatePercent: 1,
deposit: function addMoney(amount) {
if (amount > 0) {
savingsAccount.balance += amount;
}
},
withdraw: function removeMoney(amount) {
var verifyBalance = savingsAccount.balance - amount;
if (amount > 0 && verifyBalance >= 0) {
savingsAccount.balance -= amount;
}
},
printAccountSummary: function (){
return "Welcome!\nYour balance is currently $" + this.balance + " and your interest rate is " + this.interestRatePercent + "%.";
}
};
console.log(savingsAccount.deposit(2000));
console.log(savingsAccount.withdraw(1000));
console.log(savingsAccount.printAccountSummary());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment