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 #1608

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

Conversation

vserhiichuk
Copy link

// export const Person = ({ person }) => ();
export const Person = ({ person }) => {
const { name, age, sex, isMarried, partnerName } = person;
const sexPartner = sex === 'm' ? 'wife' : 'husband';

Choose a reason for hiding this comment

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

Suggested change
const sexPartner = sex === 'm' ? 'wife' : 'husband';
const sexPartner = sex === 'm'
? 'wife'
: 'husband';


return (
<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.

Suggested change
<h2 className="Person__name">{`My name is ${name}`}</h2>
<h2 className="Person__name">
{`My name is ${name}`}
</h2>

return (
<section className="Person">
<h2 className="Person__name">{`My name is ${name}`}</h2>
{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.

Suggested change
{age && <p className="Person__age">{`I am ${age}`}</p>}
{age && (
<p className="Person__age">
{`I am ${age}`}
</p>
)}

{age && <p className="Person__age">{`I am ${age}`}</p>}
{isMarried
? (
<p className="Person__partner">{`${partnerName} is my ${sexPartner}`}</p>

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

Comment on lines +12 to +13
</h2>
{age && (

Choose a reason for hiding this comment

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

Suggested change
</h2>
{age && (
</h2>
{Boolean(age) && (

Comment on lines +17 to +21
)}
<p className="Person__partner">
{isMarried
? `${partnerName} is my ${sexPartner}`
: 'I am not married'}

Choose a reason for hiding this comment

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

Suggested change
)}
<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'
}

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.

3 participants