Skip to content

Instantly share code, notes, and snippets.

@desinas
Last active September 19, 2021 17:38
Show Gist options
  • Save desinas/178a335abaf2721d9699be3a40551d62 to your computer and use it in GitHub Desktop.
Save desinas/178a335abaf2721d9699be3a40551d62 to your computer and use it in GitHub Desktop.
Bank accounts 1 Quiz (7-3) of Udacity FEWD
/*
* 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 SummaryAccountPrinting() {
return "Welcome!\nYour balance is currently $1000 and your interest rate is 1%.";
}
};
console.log(savingsAccount.printAccountSummary());
@desinas
Copy link
Author

desinas commented Dec 21, 2017

What Went Well

  • Your code should have a variable savingsAccount
  • The variable savingsAccount should be an object
  • Your savingsAccount object should have a balance property
  • Your savingsAccount object should have a interestRatePercent property
  • Your savingsAccount object should have a printAccountSummary() method
  • Your printAccountSummary() method should return the correct account message

Feedback: Your answer passed all our tests! Awesome job!

@bouallati
Copy link

printAccountSummary: function () {
return "Welcome!\n" +
"Your balance is currently $" + savingsAccount.balance +
" and your interest rate is " + savingsAccount.interestRatePercent + "%.";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment