-
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 #2370
base: master
Are you sure you want to change the base?
Solution #2370
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.
you did a good job
for me the code is valid
src/makeRobot.js
Outdated
goForward(value) { | ||
if (!value) { | ||
this.coords.y += 1; | ||
|
||
return this; | ||
} | ||
|
||
if (value < 0) { | ||
return this; | ||
} | ||
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.
you could simplified this and do something like
goForward(step = 1)
// some code
return this;
},
src/makeRobot.js
Outdated
coords: { | ||
x: 0, | ||
y: 0, | ||
}, |
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.
object properties should be defined before methods, please move those to other properties 🔼
src/makeRobot.js
Outdated
goForward(value) { | ||
if (!value) { | ||
this.coords.y += 1; | ||
|
||
return this; | ||
} | ||
|
||
if (value < 0) { | ||
return this; | ||
} | ||
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.
goForward(value) { | |
if (!value) { | |
this.coords.y += 1; | |
return this; | |
} | |
if (value < 0) { | |
return this; | |
} | |
this.coords.y += value; | |
return this; | |
}, | |
goForward(value) { | |
if (value > 0) { | |
this.coords.y += 1; | |
} | |
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.
But in case the value is 9, the robot should take 9 steps, not 1. So I think your solution is wrong 😉
I think you thought about this solution:
goForward(value = 1) {
if (value > 0) {
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.
Correct, great find!
src/makeRobot.js
Outdated
return this; | ||
}, | ||
|
||
goBack(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.
please rewrite this function according to my suggestion in goForward
method
src/makeRobot.js
Outdated
return this; | ||
}, | ||
|
||
goLeft(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.
please rewrite this function according to my suggestion in goForward
method
src/makeRobot.js
Outdated
return this; | ||
}, | ||
|
||
goRight(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.
please rewrite this function according to my suggestion in goForward
method
No description provided.