Created
August 26, 2017 17:33
-
-
Save claudiainbytes/a341de2660b22d039c1c5c5435b263a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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