Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution #1421

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ievgen-nikiforov
Copy link

No description provided.

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.

Great job on implementing the solution! 🎉 Your code meets all the task requirements and constraints, correctly processing the array of people objects and dynamically creating table rows. The only potential issue is ensuring the 'tbody' element exists in the DOM before appending rows. Consider adding a check to prevent errors if the element is not present. Keep up the excellent work and continue refining your skills! 🚀

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

Comment on lines +360 to +395
for (const person of people) {
const row = document.createElement('tr');
const table = document.querySelector('tbody');

table.appendChild(row);

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

personName.textContent = person.name;
row.appendChild(personName);

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

gender.textContent = person.sex === 'm' ? 'Male' : 'Female';
row.appendChild(gender);

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

born.textContent = person.born;
row.appendChild(born);

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

died.textContent = person.died;
row.appendChild(died);

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

age.textContent = person.died - person.born;
row.appendChild(age);

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

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

Choose a reason for hiding this comment

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

Ensure that the 'tbody' element exists in the DOM before attempting to append rows to it. If the 'tbody' element is not present when the script runs, the 'querySelector' call will return null, leading to an error when trying to append a child to it. Consider adding a check to ensure 'table' is not null before proceeding with appending rows.

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