Quiz: Contas de banco 1 (7-3)

Instruções:

Usando o dado objeto:
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;
    }
  }
};
adicione um método printAccountSummary() que retorne a seguinte mensagem de conta:
Welcome!
Your balance is currently $1000 and your interest rate is 1%.


Código


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 (amount){
return "Welcome!\nYour balance is currently $" + savingsAccount.balance
+ " and your interest rate is " + savingsAccount.interestRatePercent + "%.";
}
};

console.log(savingsAccount.printAccountSummary());

Comentários

Postagens mais visitadas deste blog

Quiz Verificando seu saldo

Quiz: Morrendo de rir 1 (5-1)