Repository navigation
add solution - #1915
add solution#1915olena0112 wants to merge 1 commit into
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
| // 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); | ||
|
|
There was a problem hiding this comment.
The table element is queried inside the for loop, which is inefficient. Query .dashboard once before the loop and reuse that reference.
https://olena0112.github.io/js_task_generate_table_DOM/