Skip to content

add solution#1766

Open
Yevhen-Srdk wants to merge 1 commit intomate-academy:masterfrom
Yevhen-Srdk:develop
Open

add solution#1766
Yevhen-Srdk wants to merge 1 commit intomate-academy:masterfrom
Yevhen-Srdk:develop

Conversation

@Yevhen-Srdk
Copy 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 work on this task! I'm approving your solution as it meets all the requirements. The table is generated correctly, and the age and century values are calculated perfectly.

As a point of improvement for the future, you could combine the two separate loops into a single one. Instead of first iterating to add the age and century properties to the objects and then iterating again to build the table, you can perform both operations in one pass. This is more efficient and avoids modifying the original people array, which is a good practice to prevent side effects.

This is just a suggestion for optimization, and your current implementation is fully correct. 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 +357 to +360
people.forEach((person) => {
person.age = getPersonAge(person);
person.century = getPersonCentury(person);
});

Choose a reason for hiding this comment

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

This loop iterates over the people array to add age and century properties, and then a second loop on line 365 iterates over it again to build the table. These two operations can be combined into a single loop for better efficiency.

This would also allow you to avoid modifying (mutating) the original person objects, which is a good practice to prevent unexpected side effects. The values for age, century, and the formatted gender can be calculated and used directly when creating the table cells.

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