-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
js-pre-oop #627
js-pre-oop #627
Conversation
What I did:
|
Hey! Congratulations on your PR! 😎😎😎 Let's do some self-checks to fix most common issues and to make some improvements to the code before reviewers put their hands on the code. Go through the requirements/most common mistakes linked below and fix the code as appropriate. If you have any questions to requirements/common mistakes feel free asking them here or in Students' chat. When you genuinely believe you are done put a comment stating that you have completed self-checks and fixed code accordingly. Also, be aware, that if you would silently ignore this recommendation, a mentor can think that you are still working on fixes. And your PR will not be reviewed. 😒 Please, make sure that your code follows the requirements based on the most common mistakes as well as basic requirements from the original task. Universal recommendations:
By the way, you may proceed to the next task before this one is reviewed and merged. Sincerely yours, |
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.
@merowing well done!
Check comments below for ideas to absorb and use when solving coding problems.
data.catWoman.say = data.cat.say; | ||
data.woman.species = data.man.species; | ||
|
||
const sequences = ['species', 'name', 'gender', 'hands', 'legs', 'say', 'friends']; |
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.
Devise a better naming. What does the variable actually contain?
case 'name': | ||
value = `<strong>${creature[creatureProperty]}</strong>`; | ||
break; |
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.
switch
is an impretaive way to write code.
Consider using a dictionary (object literal) to define modifiers for properties. Then building an output could be as short as .map(propertyName => `<${tags[propertyName]}>${creature[propertyName]}</${tags[propertyName]}>` )
This way the code would be more declarative, i.e. easier to read and modify.
P.S. There are "null" tags that you could benefit from.
Also consider splitting the handling of properties into a chain of transformations.
E.g. "Remove values that are 'empty', convert arrays into strings, format strings".
Having multiple simple operations vs one complex operation adds to readability and maintainability of code.
js-pre-oop
Demo |
Code base
This is the tiny JS World.
The code is submitted in a dedicated feature branch.
Only code files are submitted.
Please, review.