-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
base: master
Are you sure you want to change the base?
solution #1421
Conversation
There was a problem hiding this 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! ✨
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); | ||
} |
There was a problem hiding this comment.
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.
No description provided.