Skip to content

add solution - #1915

Open
olena0112 wants to merge 1 commit into
mate-academy:masterfrom
olena0112:develop
Open

olena0112 wants to merge 1 commit into
mate-academy:masterfrom
olena0112:develop

Conversation

@olena0112

Copy link
Copy Markdown

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Your solution correctly implements all required functionality. The code successfully converts the people array to table rows with all 6 required cells (name, gender, born, died, age, century), calculates age and century correctly, finds the dashboard table, and appends rows to it.

There is one minor improvement worth noting: the table element is queried inside the for loop (around line 386), which causes an unnecessary DOM query on each iteration. Moving document.querySelector('.dashboard') outside the loop before iterating would be more efficient, though this doesn't affect the correctness of your implementation.

Great job on meeting all the functional requirements!


✨ 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 360 to +386
// write your code here
for (const person of people) {
const row = document.createElement('tr');
const fullName = document.createElement('td');

fullName.textContent = person.name;

const gender = document.createElement('td');

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

const born = document.createElement('td');

born.textContent = person.born;

const died = document.createElement('td');

died.textContent = person.died;

const age = document.createElement('td');

age.textContent = person.died - person.born;

const century = document.createElement('td');

century.textContent = Math.ceil(person.died / 100);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The table element is queried inside the for loop, which is inefficient. Query .dashboard once before the loop and reuse that reference.

@2pasha 2pasha left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lgtm 🔥

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.

3 participants