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

add task solution #1616

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

add task solution #1616

wants to merge 5 commits into from

Conversation

cty2802
Copy link

@cty2802 cty2802 commented Aug 22, 2023

<h2 className="Person__name">{`My name is ${person.name}`}</h2>

<>
{person.age && (

Choose a reason for hiding this comment

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

Let's get needed properties from person object using destructuring before the return statement

Comment on lines 16 to 22
{person.isMarried && person.sex === 'm' && (
<>{`${person.partnerName} is my wife`}</>
)}
{person.isMarried && person.sex === 'f' && (
<>{`${person.partnerName} is my husband`}</>
)}
{!person.isMarried && <>I am not married</>}

Choose a reason for hiding this comment

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

You've repeated some part of code
Will be better to define the info about the partner initially, should it be wife or husband
And then use this data while preparing the content

Copy link

@roman-mirzoian roman-mirzoian 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, but there is quite a bit of work to be done.

Comment on lines 4 to 5
const WOMAN_GENDER = 'f';
const MAN_GENDER = 'm';

Choose a reason for hiding this comment

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

Such constants are better defined outside the component.

<section className="Person">
<h2 className="Person__name">{`My name is ${name}`}</h2>

<>

Choose a reason for hiding this comment

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

Do we really need to wrap everything in a fragment here?


function getMarriedInfo() {
if (sex === MAN_GENDER && isMarried) {
return <>{`${partnerName} is my wife`}</>;

Choose a reason for hiding this comment

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

Do we really need to wrap everything in a fragment here?

}

if (sex === WOMAN_GENDER && isMarried) {
return <>{`${partnerName} is my husband`}</>;

Choose a reason for hiding this comment

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

Do we really need to wrap everything in a fragment here?

return <>{`${partnerName} is my husband`}</>;
}

return <>I am not married</>;

Choose a reason for hiding this comment

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

Do we really need to wrap everything in a fragment here?

partnerName,
} = person;

function getMarriedInfo() {

Choose a reason for hiding this comment

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

Such a function can also be taken outside the component definition.

Copy link

@roman-mirzoian roman-mirzoian left a comment

Choose a reason for hiding this comment

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

Well done, but pay attention to the comment.


const MAN_GENDER = 'm';

function getMarriedInfo(status, gender, companion) {

Choose a reason for hiding this comment

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

It is worth choosing more meaningful names for arguments so that they explain what is happening in the code.

Suggested change
function getMarriedInfo(status, gender, companion) {
function getMarriedInfo(isMarried, gender, partnerName) {

Copy link

@BudnikOleksii BudnikOleksii 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!

Comment on lines +28 to +32
{age && (
<p className="Person__age">
{`I am ${age}`}
</p>
)}

Choose a reason for hiding this comment

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

If the "age" is 0 we will get the 0 shown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants