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

tiny js world #190

Merged
merged 3 commits into from
Aug 19, 2022
Merged

tiny js world #190

merged 3 commits into from
Aug 19, 2022

Conversation

SergeyShytikov
Copy link
Contributor

tiny JS world

Demo |
Code base

The code is submitted in a dedicated feature branch.

Only code files are submitted.

Please, review.

@SergeyShytikov SergeyShytikov changed the title added js for checking tiny js world Aug 16, 2022
Copy link
Member

@OleksiyRudenko OleksiyRudenko left a 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.

Comment on lines 64 to 66
function getPropertiesValueToString(obj) {
return print(Object.values(obj).join('; '))
}
Copy link
Member

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.

Copy link
Contributor Author

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.

@OleksiyRudenko OleksiyRudenko self-assigned this Aug 16, 2022
Copy link
Member

@OleksiyRudenko OleksiyRudenko left a 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.

Comment on lines 73 to 74
const mappedInhabitants = inhabitants.map(obj => keysOrder.map(key => obj[key])) ;
mappedInhabitants.forEach(item => print(item.join('; ')));
Copy link
Member

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).

Copy link
Contributor Author

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.

Copy link
Member

@OleksiyRudenko OleksiyRudenko left a 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.

@OleksiyRudenko OleksiyRudenko merged commit f73cf1e into kottans:main Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants