Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,24 @@ const people = [
// eslint-disable-next-line no-console
console.log(people); // you can remove it

// write your code here
const table = document.querySelector('.dashboard');

people.forEach((person) => {
const tr = document.createElement('tr');
const values = [
person.name,
person.sex,
person.born,
person.died,
person.died - person.born,
Math.ceil(person.died / 100),
];

values.forEach((value) => {
const td = document.createElement('td');

td.textContent = value;
tr.append(td);
table.append(tr);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Think about when a table row is fully constructed and ready to be added to the table. Right now, you're appending the row (tr) inside the loop that creates each cell (td). This means for each person, an incomplete row is added to the table multiple times. This line should be moved outside of the values.forEach loop, but still inside the people.forEach loop.

});
});
Loading