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

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

Conversation

jakubMikolajczykTech
Copy link

No description provided.

Copy link

@choeqq choeqq left a comment

Choose a reason for hiding this comment

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

please use modern JS practices and you're good to go 🚀

Comment on lines -3 to -39
/**
* Mate Robot Factory impressed by your success, they are ready to accept
* you into the Tech team, you will learn to program robots together
* with the team! Are you in business As a test task, you will need to
* program our equipment that makes robots.
*
* Create a makeRobot function that takes the string name and the number
* wheels, version and returns the robot object.
* The robot coming off the assembly line must be able to:
* - Provide information about yourself through getter info.
* robot.info === 'name:%name%, chip version: %version%, wheels: %wheels%'
* - Provide the coordinates of your location via getter location.
* robot.location === '%name%: x=14, y=21'
* - Have methods to move goForward, goBack, goRight, goLeft.
* - Movement methods must be able to be used with a chain.
* robot.goForward().goForward().goForward().goLeft()
* - Default methods that move the work by 1 in the right direction.
* This value can be increased by passing the desired number to the method.
* Negative numbers should not affect the location of the robot. goLeft(3)
* - The coordinates of the robot must be stored in the object coords,
* the keys x and y inside the robot.
* - The robot must be able to request the evacuation of robot.evacuate(),
* which will call rescuers and transfer it to the service center
* at the coordinates x: 1400, y: 500.
*
* @typedef {object} Robot
* @property {string} name
* @property {number} wheels
* @property {number} version
* @property {function} info
*
* @param {string} name
* @param {number} wheels
* @param {number} version
*
* @return {Robot}
*/
Copy link

Choose a reason for hiding this comment

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

you don't have to remove that

src/makeRobot.js Outdated
Comment on lines 14 to 74
Object.defineProperties(robot, {
info: {
get() {
return (`name: ${this.name}, chip version: ${this.version}, `
+ `wheels: ${this.wheels}`).trim();
},
},

location: {
get() {
return `${this.name}: x=${this.coords.x}, y=${this.coords.y}`;
},
},

goForward: {
value(step = 1) {
if (step > 0) {
this.coords.y += step;
}

return this;
},
},

goBack: {
value(step = 1) {
if (step > 0) {
this.coords.y -= step;
}

return this;
},
},

goRight: {
value(step = 1) {
if (step > 0) {
this.coords.x += step;
}

return this;
},
},

goLeft: {
value(step = 1) {
if (step > 0) {
this.coords.x -= step;
}

return this;
},
},

evacuate: {
value() {
this.coords.x = 1400;
this.coords.y = 500;
},
},
});
Copy link

Choose a reason for hiding this comment

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

all of those function should go inside robot object as methods - checklist point 2

src/makeRobot.js Outdated
Comment on lines 15 to 73
info: {
get() {
return (`name: ${this.name}, chip version: ${this.version}, `
+ `wheels: ${this.wheels}`).trim();
},
},

location: {
get() {
return `${this.name}: x=${this.coords.x}, y=${this.coords.y}`;
},
},

goForward: {
value(step = 1) {
if (step > 0) {
this.coords.y += step;
}

return this;
},
},

goBack: {
value(step = 1) {
if (step > 0) {
this.coords.y -= step;
}

return this;
},
},

goRight: {
value(step = 1) {
if (step > 0) {
this.coords.x += step;
}

return this;
},
},

goLeft: {
value(step = 1) {
if (step > 0) {
this.coords.x -= step;
}

return this;
},
},

evacuate: {
value() {
this.coords.x = 1400;
this.coords.y = 500;
},
},
Copy link

Choose a reason for hiding this comment

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

those are methods not properties

Copy link

@choeqq choeqq left a comment

Choose a reason for hiding this comment

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

Waiting for any updatse @kabakTech 👀

Copy link

@choeqq choeqq left a comment

Choose a reason for hiding this comment

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

Good job ✅

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.

2 participants