-
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
add task solution #2530
base: master
Are you sure you want to change the base?
add task solution #2530
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.
Almost done, let's make a little improvements
src/makeRobot.js
Outdated
goBack(steps = 1) { | ||
if (steps > 0) { | ||
this.coords.y -= steps; | ||
} | ||
|
||
return this; | ||
}, | ||
goRight(steps = 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.
goBack(steps = 1) { | |
if (steps > 0) { | |
this.coords.y -= steps; | |
} | |
return this; | |
}, | |
goRight(steps = 1) { | |
goBack(steps = 1) { | |
if (steps > 0) { | |
this.coords.y -= steps; | |
} | |
return this; | |
}, | |
goRight(steps = 1) { |
Add empty line between methods
src/makeRobot.js
Outdated
}, | ||
get info() { | ||
const robotName = `name: ${this.name}, `; | ||
const robotInfo = `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.
Or you can use concatenation instead
src/makeRobot.js
Outdated
this.coords.x = 1400; | ||
this.coords.y = 500; | ||
|
||
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.
You are not going to call this method in the chain, so no need to return this
here
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 info() { | ||
return 'name: ' + this.name + ', chip version: ' | ||
+ this.version + ', wheels: ' + this.wheels; | ||
}, | ||
get location() { | ||
return this.name + ': x=' + this.coords.x + ', y=' + this.coords.y; | ||
}, | ||
goForward(steps = 1) { | ||
if (steps > 0) { | ||
this.coords.y += steps; | ||
} | ||
|
||
return this; | ||
}, | ||
goBack(steps = 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.
get info() { | |
return 'name: ' + this.name + ', chip version: ' | |
+ this.version + ', wheels: ' + this.wheels; | |
}, | |
get location() { | |
return this.name + ': x=' + this.coords.x + ', y=' + this.coords.y; | |
}, | |
goForward(steps = 1) { | |
if (steps > 0) { | |
this.coords.y += steps; | |
} | |
return this; | |
}, | |
goBack(steps = 1) { | |
get info() { | |
return 'name: ' + this.name + ', chip version: ' | |
+ this.version + ', wheels: ' + this.wheels; | |
}, | |
get location() { | |
return this.name + ': x=' + this.coords.x + ', y=' + this.coords.y; | |
}, | |
goForward(steps = 1) { | |
if (steps > 0) { | |
this.coords.y += steps; | |
} | |
return this; | |
}, | |
goBack(steps = 1) { |
Add empty line between all your methods
No description provided.