Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #2334

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #2334

wants to merge 1 commit into from

Conversation

DariaNastas
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on the Pull Request! Just a little tip for the future: consider using the method shorthand syntax in your objects to make your code cleaner and more modern. Keep up the good work! 😊👍

Comment on lines +9 to +13
add: function (value) {
this.result += value;

return this;
},

Choose a reason for hiding this comment

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

Instead of using the function keyword, you can use the method shorthand syntax to define methods within the calculator object.

Comment on lines +15 to +19
subtract: function (value) {
this.result -= value;

return this;
},

Choose a reason for hiding this comment

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

Use the method shorthand syntax for defining the subtract method.

Comment on lines +21 to +25
multiply: function (value) {
this.result *= value;

return this;
},

Choose a reason for hiding this comment

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

Use the method shorthand syntax for defining the multiply method.

Comment on lines +27 to +31
divide: function (value) {
this.result /= value;

return this;
},

Choose a reason for hiding this comment

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

Use the method shorthand syntax for defining the divide method.

Comment on lines +33 to +37
reset: function () {
this.result = 0;

return this;
},

Choose a reason for hiding this comment

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

Use the method shorthand syntax for defining the reset method.

Comment on lines +39 to +41
operate: function (operation, value) {
return operation.call(this, value);
},

Choose a reason for hiding this comment

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

Use the method shorthand syntax for defining the operate method.

// write code here
const calculator = {
result: 0,
add: function (value) {

Choose a reason for hiding this comment

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

Suggested change
add: function (value) {
add(value) {

we can simplify that

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! now that's how I'll write ;)

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.

None yet

3 participants