-
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 #2390
base: master
Are you sure you want to change the base?
Solution #2390
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.
please use modern JS practices and you're good to go 🚀
/** | ||
* 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} | ||
*/ |
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 don't have to remove that
src/makeRobot.js
Outdated
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; | ||
}, | ||
}, | ||
}); |
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.
all of those function should go inside robot object as methods - checklist point 2
src/makeRobot.js
Outdated
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; | ||
}, | ||
}, |
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.
those are methods not properties
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.
Waiting for any updatse @kabakTech 👀
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.
Good job ✅
No description provided.