From 365a5a0b2597f109597687643c416265e39de270 Mon Sep 17 00:00:00 2001 From: yarynaburenko Date: Wed, 2 Oct 2024 17:54:09 +0300 Subject: [PATCH 1/2] add solution --- src/components/Person/Person.jsx | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/components/Person/Person.jsx b/src/components/Person/Person.jsx index eccf156a3..f37738bc7 100644 --- a/src/components/Person/Person.jsx +++ b/src/components/Person/Person.jsx @@ -1 +1,24 @@ -// export const Person = ({ person }) => (); +import React from 'react'; + +const Person = ({ person }) => { + const renderPartner = () => { + if (!person.isMarried) { + return 'I am not married'; + } + + return person.gender === 'male' + ? `${person.partnerName} is my wife` + : `${person.partnerName} is my husband`; + }; + + return ( +
+

{person.name}

+ {person.age &&

Age: {person.age}

} + +

{renderPartner()}

+
+ ); +}; + +export default Person; From 5e7ed6721be77d990840b9d9daf39a49d401a0bf Mon Sep 17 00:00:00 2001 From: yarynaburenko Date: Wed, 2 Oct 2024 17:55:00 +0300 Subject: [PATCH 2/2] add base file --- src/App.jsx | 70 +++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 40 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index dcf8509c8..dbf1a8905 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,45 +1,35 @@ -import React from 'react'; -import './App.scss'; +import Person from './components/Person/Person'; -export const misha = { - name: 'Misha', - age: 37, - sex: 'm', - isMarried: true, - partnerName: 'Natasha', -}; +export const App = () => { + const misha = { + name: 'My name is Misha', + age: 37, + isMarried: true, + gender: 'male', + partnerName: 'Natasha', + }; -export const olya = { - name: 'Olya', - sex: 'f', - isMarried: true, - partnerName: 'Maksym', -}; + const olya = { + name: 'My name is Olya', + isMarried: true, + gender: 'female', + partnerName: 'Maksym', + }; -export const alex = { - name: 'Alex', - age: 25, - sex: 'm', - isMarried: false, -}; + const alex = { + name: 'My name is Alex', + age: 25, + isMarried: false, + gender: 'male', + }; -export const App = () => ( -
-
-

My name is Misha

-

I am 37

-

Natasha is my wife

-
- -
-

My name is Olya

-

Maksym is my husband

-
+ return ( +
+ + + +
+ ); +}; -
-

My name is Alex

-

I am 25

-

I am not married

-
-
-); +export default App;