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

a-tiny-JS-world #36

Merged
merged 7 commits into from
Aug 15, 2022
Merged

a-tiny-JS-world #36

merged 7 commits into from
Aug 15, 2022

Conversation

Eugene-CG
Copy link
Contributor

a-tiny-JS-world

Demo
Code base

The code is submitted in a dedicated feature branch.

Only code files are submitted.

Please, review.

Copy link

@al0tak al0tak 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! Now let's make it even better.

gender: "female",
legs: 2,
hands: 2,
saying: cat.saying,
Copy link

Choose a reason for hiding this comment

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

Here you are only copying the initial value of the cat.saying. You have to figure out some way to connect those values, so that if you change cat.saying, catWoman.saying changes as well.

hands: 2,
saying: cat.saying,
};
const arr = [cat, dog, man, woman, catWoman];
Copy link

Choose a reason for hiding this comment

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

Avoid using data types in the name of the variable. It is a clear indicator that your variable name isn't as obvious as it should be. Let's take this one for example. arr of what? If you use this variable outside this code somewhere, would you be able to understand what data is inside? Let's replace it with something like inhabitants. This gives you and understanding of what data is there and the fact that this is plural suggests that this is an array as well.

saying: cat.saying,
};
const arr = [cat, dog, man, woman, catWoman];
let string = [];
Copy link

Choose a reason for hiding this comment

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

Same thing, but even more confusing. A string that is actually and array? Also, you could've printed every inhabitants info separately, it is not against the task, but since you are already doing this, why let? You are not replacing the value anywhere, you are using push. It is allowed to change the value of arrays with functions like push even when the variable is a const.

@Eugene-CG
Copy link
Contributor Author

catWoman.prototype = cat.prototype, but I used Object.setPrototypeOf, because Object.create(prototype, descriptors) dont work properly, I dont know why.
Object.create(getPrototypeOf(cat), ...) dont work

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.

@Eugene-CG good job!
A bit of improvement and we are done.

Comment on lines 71 to 73
inhabitantsKeys.reduce((accumulator, prop) => {
return (accumulator += obj[prop] + "; ");
}, "")
Copy link
Member

Choose a reason for hiding this comment

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

Consider using #Array.map (to map property names into values) and #Array.join (to glue substrings together) here. This will make the code cleaner.

@Eugene-CG Eugene-CG closed this Aug 7, 2022
@Eugene-CG Eugene-CG reopened this Aug 9, 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.

@Eugene-CG well done!
Check the comment below to improve your code style a bit..

Comment on lines +71 to +73
inhabitantsKeys.map((prop) => {
return obj[prop];
})
Copy link
Member

Choose a reason for hiding this comment

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

This can be reduced to inhabitantsKeys.map(prop => obj[prop]). return statement and surrounding {} are redundant if return is the only statement in arrow function body.

@OleksiyRudenko OleksiyRudenko merged commit f9cb08c into kottans:main Aug 15, 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