Skip to content
Closed
Changes from all commits
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
33 changes: 30 additions & 3 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,34 @@ const people = [
},
];

// eslint-disable-next-line no-console
console.log(people); // you can remove it
function createRow(item) {
const tr = document.createElement('tr');
const td1 = document.createElement('td');
const td2 = document.createElement('td');
const td3 = document.createElement('td');
const td4 = document.createElement('td');
const td5 = document.createElement('td');
const td6 = document.createElement('td');
const age = item.died - item.born;
const century = Math.ceil(item.died / 100);

// write your code here
td1.textContent = item.name;
td2.textContent = item.sex === 'm' ? 'Male' : 'Female';
td3.textContent = item.born;
td4.textContent = item.died;
td5.textContent = age;
td6.textContent = century;

tr.append(td1, td2, td3, td4, td5, td6);

return tr;
}

const table = document.querySelector('.dashboard');
const tbody = table.querySelector('tbody');

people.forEach((item) => {
const tr = createRow(item);

tbody.append(tr);
});
Loading