Skip to content

Commit

Permalink
updated solution
Browse files Browse the repository at this point in the history
  • Loading branch information
oksana-vas committed Aug 17, 2023
1 parent 5202d76 commit d3a7dd1
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions src/components/Person/Person.jsx
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>
);
};

0 comments on commit d3a7dd1

Please sign in to comment.