Solution#3726
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation correctly fulfills all core functional requirements - the Person component properly displays names, conditionally shows age, and handles gender-specific partner terminology exactly as specified. All test cases pass.
However, there are 3 checklist style violations that should be addressed:
-
[CHECKLIST ITEM #1] The
personprop is destructured in the function signature, but you then access properties viaperson.name,person.age, etc. instead of destructuring those properties directly. Addconst { name, age, sex, isMarried, partnerName } = person;at the beginning of your component. -
[CHECKLIST ITEM #2] The ternary operator in your JSX has operands on the same line. Move each operand to a separate line for better readability.
-
[CHECKLIST ITEM #3] The
isMarriedcondition appears inline in your JSX ternary expression. Extract it to a variable likeconst partnerText = isMarried ? ... : ...;before the return statement.
Additionally, remove the commented-out code on line 2: // export const Person = ({ person }) => ();
These are style guideline violations - the functionality works perfectly, so your solution is approved. Consider fixing these issues to improve code quality.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| @@ -1 +1,16 @@ | |||
| // export const Person = ({ person }) => (); | |||
| export const Person = ({ person }) => ( | |||
There was a problem hiding this comment.
This violates checklist item #1: 'Use destructuring for getting access to values of props object'. The component receives person as a destructured prop but then accesses all properties via person.propertyName instead of destructuring the person object's properties directly.
| {person.isMarried | ||
| ? `${person.partnerName} is my ${person.sex === 'm' ? 'wife' : 'husband'}` |
There was a problem hiding this comment.
This violates checklist item #2: 'Format ternary operator operands correctly - move each operand to the separate line'. The ternary operands should be on separate lines for better readability.
| {person.age && <p className="Person__age">I am {person.age}</p>} | ||
| <p className="Person__partner"> | ||
| {person.isMarried | ||
| ? `${person.partnerName} is my ${person.sex === 'm' ? 'wife' : 'husband'}` |
There was a problem hiding this comment.
This violates checklist item #3: 'Avoid putting several cases to conditional rendering. Create separate variable for the condition'. The nested ternary person.sex === 'm' ? 'wife' : 'husband' should be extracted to a separate variable.
https://cassiaqueiroz.github.io/react_person/