-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
base: master
Are you sure you want to change the base?
Solution #2334
Conversation
There was a problem hiding this 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! 😊👍
add: function (value) { | ||
this.result += value; | ||
|
||
return this; | ||
}, |
There was a problem hiding this comment.
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.
subtract: function (value) { | ||
this.result -= value; | ||
|
||
return this; | ||
}, |
There was a problem hiding this comment.
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.
multiply: function (value) { | ||
this.result *= value; | ||
|
||
return this; | ||
}, |
There was a problem hiding this comment.
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.
divide: function (value) { | ||
this.result /= value; | ||
|
||
return this; | ||
}, |
There was a problem hiding this comment.
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.
reset: function () { | ||
this.result = 0; | ||
|
||
return this; | ||
}, |
There was a problem hiding this comment.
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.
operate: function (operation, value) { | ||
return operation.call(this, value); | ||
}, |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add: function (value) { | |
add(value) { |
we can simplify that
There was a problem hiding this comment.
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 ;)
No description provided.