-
-
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
tiny js world #190
tiny js world #190
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.
@SergeyShytikov good job!
Please check the comment below.
function getPropertiesValueToString(obj) { | ||
return print(Object.values(obj).join('; ')) | ||
} |
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.
Looks like a generic method to convert any object into a string.
However, as the task requires specific order of properties listed Object
methods like keys
, values
, entries
shouldn't be used as these do not guarantee any particular order of keys/values.
Once you solve this the method will stop being generic but rather specific to our domain (Tiny JS World and its inhabitants). Thus you will need to reflect this specificity in function and its parameter names.
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.
Thanks for the advice, for some reason I did not read all the requirements of the task.
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.
@SergeyShytikov well done!
A few things to improve and we are done.
const mappedInhabitants = inhabitants.map(obj => keysOrder.map(key => obj[key])) ; | ||
mappedInhabitants.forEach(item => print(item.join('; '))); |
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.
If we chain inhabitants.map
and following forEach
we do not need an extra variable.
obj
is too generic. As a peer developer I want to read instantly what objects we work here with.
Same is about item
.
Do not use generic variable names unless it is a function specifically designed to work with multiple types of instances (e.g. we are building a generic data processing library).
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 right, after a while I won't be able to figure out what's going on here, either.
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.
@SergeyShytikov well done, grats!
P.S. Please install prettier.io plugin on your IDE for it to take care of formatting and code style for you. On bigger codebase it is worth it definitely.
tiny JS world
Demo |
Code base
The code is submitted in a dedicated feature branch.
Only code files are submitted.
Please, review.