-
-
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
Task a Tiny JS World #271
Task a Tiny JS World #271
Conversation
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 -- (pre-OOP) exercise check listRelates to Object-Oriented JavaScript task. Check-list - definition of done
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, |
Made some self-checks to fix most common issues |
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.
@OlexiyDobroskok quite a decent job done!
Let's polish it.
const allProperties = []; | ||
properties.forEach((prop) => { | ||
if (resident[prop] !== 0) { | ||
allProperties.push(resident[prop]); | ||
} | ||
}); | ||
return allProperties; |
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.
A classic use case for Array#map
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.
Done =)
Removed the variable and made the return immediately. I forget I can do that =)))) |
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.
@OlexiyDobroskok great job!
CHeck the comment below for a learning to use.
.map((prop) => { | ||
return resident[prop]; | ||
}) |
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 an arrow function has a single statement and the statement is return
, you do not need neither surrounding curly braces nor return
keyword.
Also if an arrow function has exactly one argument parentheses can be skipped.
Compare readability:
.map((prop) => {
return resident[prop];
})
.map(prop => resident[prop])
Same refers to the enclosing function in this case. Proper formatting will help to keep nested code radable.
A Tiny JS World
Demo |
Code base
The code is submitted in a dedicated feature branch.
Only code files are submitted.
Please, review.