-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 #1589
base: master
Are you sure you want to change the base?
add task solution #1589
Conversation
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.
Some comments below
src/components/Person/Person.jsx
Outdated
if (sex === SEX_FEMALE) { | ||
return ( | ||
<p className="Person__partner">{`${partnerName} is my husband`}</p> | ||
); | ||
} | ||
|
||
if (sex === SEX_MALE) { | ||
return ( | ||
<p className="Person__partner">{`${partnerName} is my wife`}</p> | ||
); | ||
} |
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.
Maybe we can simplify this. The only difference between these 2 returns is the partner wife
or husband
. So better to use ternary here
src/components/Person/Person.jsx
Outdated
<section className="Person"> | ||
<h2 className="Person__name">{`My name is ${name}`}</h2> | ||
|
||
{typeof age === 'number' && ( |
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.
{typeof age === 'number' && ( | |
{!!age && ( |
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 age === 0 ?
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.
Good job!
{ isMarried | ||
? (<p className="Person__partner">{`${partnerName} is my ${getPartnerStatus(sex)}`}</p>) | ||
: (<p className="Person__partner">I am not married</p>) |
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.
You can put this condition inside "Person__partner" element, as it's used in both cases
<section className="Person"> | ||
<h2 className="Person__name">{`My name is ${name}`}</h2> | ||
|
||
{!!age && ( |
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.
It's not critical, but would be great to check if the age is a positive number
DEMO LINK