Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great job implementing the core logic to generate the table and calculate the age and century. Your code successfully handles most of the requirements.
However, I'm requesting one change to meet the task's specifications. The gender is currently displayed as 'Male' or 'Female', but the reference image in the task description shows it should be 'm' or 'f'. Please adjust the code to use the original sex property from the person object directly.
I also have a couple of suggestions for improvement:
- Avoid using 'magic numbers' like
6in your loop. It's more robust to loop over the data array itself, for example with afor...ofloop. - Consider refining the
genPersonDatafunction to accept a single person object (function genPersonData(person)) instead of the entire array and an index. This makes the function more reusable and easier to understand.
Once the gender formatting is corrected, this will be ready for approval!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
src/scripts/main.js
Outdated
| return Math.ceil(x); | ||
| } | ||
|
|
||
| function genPersonData(peop, ind) { |
There was a problem hiding this comment.
This function accepts the entire peop array and an index ind, but it only uses one element from the array. A cleaner approach is to pass only the data the function needs, which is a single person object. Consider changing the signature to function genPersonData(person) and calling it inside the loop with genPersonData(people[r]).
src/scripts/main.js
Outdated
| if (peop[ind].sex === 'm') { | ||
| poplSex = 'Male'; | ||
| } else { | ||
| poplSex = 'Female'; | ||
| } |
There was a problem hiding this comment.
According to the reference image in the task description, the gender should be displayed as 'm' or 'f'. This code changes it to 'Male' or 'Female', which does not match the expected output. The original sex property from the person object should be used directly.
src/scripts/main.js
Outdated
|
|
||
| const currentPerson = genPersonData(people, r); | ||
|
|
||
| for (let i = 0; i < 6; i++) { |
There was a problem hiding this comment.
Using a hardcoded number like 6 here is considered a 'magic number' and can make the code fragile. If you were to add another piece of data to display, you'd have to remember to change this number too. It's safer to rely on the length of the data you're iterating over, like currentPerson.length. A for...of loop would be even better here.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because the critical issue from the previous review regarding the gender format has not been addressed. Your code correctly calculates the age and century, but the gender is displayed as 'Male' or 'Female' instead of the required 'm' or 'f'. Please remove the if/else block in src/scripts/main.js that performs this conversion and use the peop.sex property directly from the data. Once this is fixed, your solution will be ready for approval.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| if (peop.sex === 'm') { | ||
| poplSex = 'Male'; | ||
| } else { | ||
| poplSex = 'Female'; | ||
| } |
There was a problem hiding this comment.
This logic for determining the gender is still not quite right. The task requires displaying the gender as 'm' or 'f', as seen in the reference image. This if/else block converts it to 'Male' or 'Female'.
You can remove this block and use the peop.sex value directly when creating the person array.
There was a problem hiding this comment.
"This logic for determining the gender is still not quite right. The task requires displaying the gender as 'm' or 'f', as seen in the reference image. This if/else block converts it to 'Male' or 'Female'.
You can remove this block and use the peop.sex value directly when creating the person array."
If I do this, the test will fail.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving your solution as an educational override to help you move forward. You've done a great job correctly calculating the age and century and building the table structure.
The one critical piece of feedback from the previous review still needs to be addressed. In src/scripts/main.js, the if/else block is still converting the gender to 'Male'/'Female'. The requirement is to display the original 'm' or 'f' value from the data.
To fix this, please remove that if/else block and use the peop.sex value directly. Once that change is made, your code will be perfect. Keep up the excellent work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| if (peop.sex === 'm') { | ||
| poplSex = 'Male'; | ||
| } else { | ||
| poplSex = 'Female'; | ||
| } |
There was a problem hiding this comment.
This if/else block is converting the gender from 'm' or 'f' to 'Male' or 'Female'. As mentioned in the previous review, this is incorrect. The requirement is to display the gender value directly from the people.json data, which is either 'm' or 'f'.
Please remove this logic and use peop.sex directly when creating the person array on line 29.
Task was completed, array converted to table.
DEMO LINK