-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5202d76
commit d3a7dd1
Showing
1 changed file
with
28 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,29 @@ | ||
export const Person = ({ person }) => ( | ||
<section className="Person"> | ||
<h2 className="Person__name">My name is {person.name}</h2> | ||
{person.age && ( | ||
<p className="Person__age">I am {person.age}</p> | ||
)} | ||
<p className="Person__partner"> | ||
{person.isMarried === false ? ( | ||
<span>I am not married</span> | ||
) : person.sex === 'f' ? ( | ||
<span>{person.partnerName} is my husband</span> | ||
) : ( | ||
<span>{person.partnerName} is my wife</span> | ||
export const Person = ({ person }) => { | ||
const isMarried = () => { | ||
if (!person.isMarried) { | ||
return 'I am not married'; | ||
} | ||
|
||
return person.sex === 'f' | ||
? `${person.partnerName} is my husband` | ||
: `${person.partnerName} is my wife`; | ||
}; | ||
|
||
return ( | ||
<section className="Person"> | ||
<h2 className="Person__name"> | ||
{`My name is ${person.name}`} | ||
</h2> | ||
|
||
{person.age && ( | ||
<p className="Person__age"> | ||
{`I am ${person.age}`} | ||
</p> | ||
)} | ||
</p> | ||
</section> | ||
); | ||
|
||
<p className="Person__partner"> | ||
{isMarried()} | ||
</p> | ||
</section> | ||
); | ||
}; |