Skip to content

Solution#1785

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

Solution#1785
ValentynaBahyrly wants to merge 1 commit intomate-academy:masterfrom
ValentynaBahyrly:develop

Conversation

@ValentynaBahyrly
Copy link
Copy Markdown

[x] DEMO LINK
[x] Your task today is to convert this array to table rows.
[x] 1) For each person from people array create table row with 6 table cells (name, gender, born, died, age, century)
[x] 2) Find a table with class dashboard in the document.
[x] 3) Append created row to table.
[x] 4) Done.

Copy link
Copy Markdown

@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 am approving your solution as it correctly implements all the requirements. The table is generated perfectly from the data, and your calculations for age and century are spot on.

As a suggestion for future improvement, it's a good practice to avoid modifying original data objects. In your code, you added a gender property directly to the person object. A more predictable approach is to store the derived value in a local variable without changing the source object, like this:

const gender = person.sex === 'm' ? 'Male' : 'Female';

This helps prevent unexpected side effects in larger applications. Keep up the excellent effort!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment thread src/scripts/main.js
Comment on lines +365 to +369
if (person.sex === 'm') {
person.gender = 'Male';
} else {
person.gender = 'Female';
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

While this code functions correctly, it modifies the original person object by adding a gender property. This is a side effect and is generally considered a practice to avoid. A better approach would be to determine the gender and store it in a local variable without altering the person object. For example:

const gender = person.sex === 'm' ? 'Male' : 'Female';

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