Build a Bank Account Management Program - Build a Bank Account Management Program

Tell us what’s happening:

I I have at least two deposits and withdrawals but the test is not passing please what’s happening
20. Your myAccount bank account should have at least two deposits.
21. Your myAccount bank account should have at least two withdrawals.

Your code so far

class BankAccount {
  constructor() {
    this.balance = 0;
    this.transactions = [];
  }

  deposit(amount) {
    if (amount <= 0) {
      return "Deposit amount must be greater than zero.";
    }
    this.balance += amount;
    this.transactions.push({amount: amount}); // Store deposit as positive
    return `Successfully deposited $${amount}. New balance: $${this.balance}`;
  }

  withdraw(amount) {
    if (amount <= 0 || this.balance - amount < 0) {
      return "Insufficient balance or invalid amount.";
    }
    this.balance -= amount;
    this.transactions.push({amount:-amount}); // Store withdrawal as negative
    return `Successfully withdrew $${amount}. New balance: $${this.balance}`;
  }

  checkBalance() {
    return `Current balance: $${this.balance}`;
  }

  listAllDeposits() {
    const deposits = this.transactions.filter(el => el.amount > 0).map(el => el.amount);
    return `Deposits: ${deposits.join(',')}`;
  }

  listAllWithdrawals() {
    const withdrawals = this.transactions.filter(el => el.amount < 0).map(el => -el.amount);
    return `Withdrawals: ${withdrawals.join(',')}`;
  }
}

const myAccount = new BankAccount();



myAccount.deposit(400);
myAccount.deposit(600);
myAccount.deposit(100);  
myAccount.withdraw(200);
myAccount.withdraw(100);
myAccount.withdraw(200); 

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36

Challenge Information:

Build a Bank Account Management Program - Build a Bank Account Management Program

your transactions are missing the type property asked in the isntructions

  1. Each transaction stored in the transactions array should be an object with two properties: type and amount. The type property should be either deposit or withdraw, and the amount property should be the amount deposited or withdrawn.