-
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 #1608
base: master
Are you sure you want to change the base?
add task solution #1608
Conversation
src/components/Person/Person.jsx
Outdated
// export const Person = ({ person }) => (); | ||
export const Person = ({ person }) => { | ||
const { name, age, sex, isMarried, partnerName } = person; | ||
const sexPartner = sex === 'm' ? 'wife' : 'husband'; |
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.
const sexPartner = sex === 'm' ? 'wife' : 'husband'; | |
const sexPartner = sex === 'm' | |
? 'wife' | |
: 'husband'; |
src/components/Person/Person.jsx
Outdated
|
||
return ( | ||
<section className="Person"> | ||
<h2 className="Person__name">{`My name is ${name}`}</h2> |
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.
<h2 className="Person__name">{`My name is ${name}`}</h2> | |
<h2 className="Person__name"> | |
{`My name is ${name}`} | |
</h2> |
src/components/Person/Person.jsx
Outdated
return ( | ||
<section className="Person"> | ||
<h2 className="Person__name">{`My name is ${name}`}</h2> | ||
{age && <p className="Person__age">{`I am ${age}`}</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.
{age && <p className="Person__age">{`I am ${age}`}</p>} | |
{age && ( | |
<p className="Person__age"> | |
{`I am ${age}`} | |
</p> | |
)} |
src/components/Person/Person.jsx
Outdated
{age && <p className="Person__age">{`I am ${age}`}</p>} | ||
{isMarried | ||
? ( | ||
<p className="Person__partner">{`${partnerName} is my ${sexPartner}`}</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.
Don't repeat yourself: the outer paragraph is the same for both cases
Change just the content depending on the variable value
</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.
</h2> | |
{age && ( | |
</h2> | |
{Boolean(age) && ( |
)} | ||
<p className="Person__partner"> | ||
{isMarried | ||
? `${partnerName} is my ${sexPartner}` | ||
: 'I am not married'} |
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.
)} | |
<p className="Person__partner"> | |
{isMarried | |
? `${partnerName} is my ${sexPartner}` | |
: 'I am not married'} | |
)} | |
<p className="Person__partner"> | |
{isMarried | |
? `${partnerName} is my ${sexPartner}` | |
: 'I am not married' | |
} |
DEMO LINK