Skip to content

Conversation

@EvaLa94
Copy link

@EvaLa94 EvaLa94 commented Feb 15, 2023

No description provided.

deposit(amount, description = "") {
if (this.checkAmount(amount)) {
this.ledger.push({ amount: +amount, description: description });
this.balance += +amount;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a good idea to put it in the method.
See the following comment.

amount: -amount,
description: description,
});
this.balance -= amount;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same situation.

* @returns {string} - returns formatted balance with two decimals
*/
getBalance() {
return +this.balance.toFixed(2);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if I asked you for the balance relating to only the first 5 movements and not the absolute balance?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I actually hadn't thought about this feature. I will solve this issue!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants