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 #2370

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Solution #2370

wants to merge 2 commits into from

Conversation

HaniaNassalska
Copy link

No description provided.

Copy link

@domalewski domalewski left a 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
Comment on lines 60 to 73
goForward(value) {
if (!value) {
this.coords.y += 1;

return this;
}

if (value < 0) {
return this;
}
this.coords.y += value;

return this;
},

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
Comment on lines 51 to 54
coords: {
x: 0,
y: 0,
},
Copy link

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
Comment on lines 60 to 73
goForward(value) {
if (!value) {
this.coords.y += 1;

return this;
}

if (value < 0) {
return this;
}
this.coords.y += value;

return this;
},
Copy link

Choose a reason for hiding this comment

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

Suggested change
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
},

Copy link
Author

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;
},

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) {
Copy link

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) {
Copy link

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) {
Copy link

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

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.

4 participants