-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 #2288
base: master
Are you sure you want to change the base?
Solution #2288
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.
A job well done, but needs some finishing touches.
src/makeRobot.js
Outdated
@@ -39,6 +39,67 @@ | |||
*/ | |||
function makeRobot(name, wheels, version) { | |||
// write code here | |||
const obj = { |
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.
The obj
is not a descriptive variable name. It is recommended to use meaningful variable names. For example, you could use robot
instead.
src/makeRobot.js
Outdated
|
||
}; | ||
|
||
obj.name = name; |
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.
If we do not change these fields ( name
, version
, and wheels
) while working with the makeRobot
function, it is better to define them at the beginning, during the creation of the object.
src/makeRobot.js
Outdated
+ ', chip version: ' | ||
+ this.version | ||
+ ', wheels: ' | ||
+ this.wheels; |
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.
You can return the string here just like you do in the getter location()
.
this.coords.y -= 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.
It is not necessary to return this
every time, if we do some operation on the data and we do not need this
as a result of execution.
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.
but without "return this" we can`t use them step by step like this :robot.goBack(1).goForward(17).goForward(-1).goLeft(3).goLeft(7).goRight();
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.
Yes, you are right 👍
+ ', wheels: ' | ||
+ this.wheels; | ||
}, | ||
get location() { |
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.
Do not forget about good formatting of the code (in this case, there is no empty line before each new method).
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.
well done!! 🎀
src/makeRobot.js
Outdated
this.coords.x = 1400; | ||
this.coords.y = 500; |
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.
get rid of magic numbers
src/makeRobot.js
Outdated
return `${name}: x=${this.coords.x}, y=${this.coords.y}`; | ||
}, | ||
|
||
goBack(value = 1) { |
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.
let's replace value with step
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.
👍
No description provided.