-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Added index.js file to rewiev #385
Conversation
d1411be
to
c03c246
Compare
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 listed/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. 😒 A Tiny JS World -- OOP exercise check listRelates to A Tiny JS World OOP exercise. Check-list - definition of doneMinimal requirements to meet:
Optional level up (not required to implement):
Bonus:
Helpful resources: Universal recommendations:
Also take a note of the requirements above and follow them in all your future projects. By the way, you may proceed to the next task before this one is reviewed and merged. Sincerely yours, |
Has completed self-checks |
Comment for activity. |
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.
@chernetskyi8704 quite a decent job!
A couple of improvements are still needed.
|
||
displayData() { | ||
return ["species", "name", "gender", "saying"] | ||
.map((data) => this[data]) |
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.
data
is a generic term. What exactly map
works with?
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.
I will take into account in the future, not to use a generic term in situations like that. Thanks a lot.
} | ||
|
||
displayData() { | ||
return `${super.displayData()}; ${this.hands}; ${this.legs};`; |
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 make this (and other similar fragments in subclasses) DRYer with Array#join
.
Do not use strings representing propety names. KISS
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 a lot. Now really code looks better.
const man = new Man("Man", "Dimitrij", "male", "Nice to meet you!", 2, 2); | ||
const woman = new Woman("Woman", "Kate", "male", "Have a good day!", 2, 2); | ||
const dog = new Dog("Dog", "Molly", "female", "WOOF-WOOF!", 4, 1); | ||
const cat = new Cat("Cat", "Whiskey", "female", "Meow!", 4, 1); |
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.
From the checklist:
No need to specify species at instantiation
There is at least two ways to achieve this. One you already use for a different property. Another one is hinted in the checklist.
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.
Think now i made it correctly.
// ======== OUTPUT ======== | ||
const allInhabitants = [man, woman, dog, cat]; | ||
|
||
allInhabitants.map((inhabitan) => { |
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.
Check English spelling.
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.
Sorry for that one, it was obvious.
I just noticed there are two submissions for TJSW OOP from you. What tasks exactly implements each of #385 and #575? Minimal requirements and hence review flow is different for pre-OOP and post-OOP. |
In #385 I perhaps make more than it requires in 'Building a Tiny JS World (pre-OOP) - practice'. First, it was written like this - chernetskyi8704/a-tiny-JS-world@dcab8f6. But then I asked in the chat if it ok and replied that I needed to be made some changes. My bad that I incorrectly read the requirements. |
Should I replace this code with the code that in the commit that I send above or just make improvements wich you pointed on? |
Hold on. I will suggest the approach so that we do not discard what's been done so far in terms of both code and review. |
Is there something requier to do from me? |
…ks with also has made rafactoring.
@chernetskyi8704 let's keep this PR for OOP version and #575 for pre-OOP version. |
@OleksiyRudenko I hope I understood you correctly. |
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.
@chernetskyi8704 nearly there
super("Man🤵", Name, Gender, Saying); | ||
} | ||
} | ||
|
||
class Woman extends Human { | ||
constructor(Name, Gender, Saying) { | ||
super("Woman👩", Name, Gender, Saying); |
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.
Men and women belong to the same species. I just cannot let heresy pass through :)
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.
Yeah, that was a stupid one.
this.Paws = "4"; | ||
this.Tail = "1"; |
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.
Not critical here, as we do not really do math operations with paws and tails.
Just wondering, why strings?
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.
Strings because of using string methods.
Should i fix it?
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.
Not necessarily. For example, telephone numbers do not actually make sense as numbers in mathematial sense, as we do not math operations over them. From the other hand we may want to count total number of legs in a herd.
Probably a missing part in your puzzle was that numbers coerce to strings automagically in string context.
Check what 4 + ""
results in and why [1, 31, 3, 5, 11].sort()
doesn't work as expected. This is an important part of understanding JS internals and peculiarities.
You may skip fixing this. Make sure to take some learnings.
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.
Type conversion it's really a great thing in JS but I'm not thought about this in the border of this task. In the future will ask my self more often 'What about if...'. Thank you so much for the review.
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.
@chernetskyi8704 great job!
OOP exercise
Demo |
Code base
The code is submitted in a dedicated feature branch.
Only code files are submitted.
Please, review.