Skip to content

Solution#1762

Open
yarovskiy-a wants to merge 5 commits intomate-academy:masterfrom
yarovskiy-a:develop
Open

Solution#1762
yarovskiy-a wants to merge 5 commits intomate-academy:masterfrom
yarovskiy-a:develop

Conversation

@yarovskiy-a
Copy link

Task was completed, array converted to table.
DEMO LINK

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 6 in your loop. It's more robust to loop over the data array itself, for example with a for...of loop.
  • Consider refining the genPersonData function 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

return Math.ceil(x);
}

function genPersonData(peop, ind) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]).

Comment on lines +375 to +379
if (peop[ind].sex === 'm') {
poplSex = 'Male';
} else {
poplSex = 'Female';
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


const currentPerson = genPersonData(people, r);

for (let i = 0; i < 6; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +375 to +379
if (peop.sex === 'm') {
poplSex = 'Male';
} else {
poplSex = 'Female';
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"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.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Rate AI review example

Comment on lines +23 to +27
if (peop.sex === 'm') {
poplSex = 'Male';
} else {
poplSex = 'Female';
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants